* Fix spec/uploaders/profile_image_uploader_spec.rb * Additional ordering based fixes * Fix spec/requests/comments_spec.rb * Fix spec
25 lines
739 B
Ruby
25 lines
739 B
Ruby
module Notifications
|
|
class ModerationNotificationWorker
|
|
include Sidekiq::Worker
|
|
|
|
sidekiq_options queue: :medium_priority, retry: 10
|
|
|
|
def perform(notifiable_id)
|
|
random_moderators = Notifications::Moderation.available_moderators.order(Arel.sql("RANDOM()")).first(2)
|
|
return unless random_moderators.any?
|
|
|
|
# notifiable is currently only comment
|
|
notifiable = Comment.find_by(id: notifiable_id)
|
|
return unless notifiable
|
|
|
|
# return if it's a comment whose commentable has been deleted
|
|
return unless notifiable.commentable
|
|
|
|
random_moderators.each do |mod|
|
|
next if mod == notifiable.user
|
|
|
|
Notifications::Moderation::Send.call(mod, notifiable)
|
|
end
|
|
end
|
|
end
|
|
end
|