2019-05-12 21:55:44 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-05-08 03:18:56 -04:00
|
|
|
module Jobs
|
2019-10-02 00:01:53 -04:00
|
|
|
class NotifyPostRevision < ::Jobs::Base
|
2019-05-08 03:18:56 -04:00
|
|
|
def execute(args)
|
2019-05-08 03:58:08 -04:00
|
|
|
raise Discourse::InvalidParameters.new(:user_ids) unless args[:user_ids]
|
2019-05-08 03:18:56 -04:00
|
|
|
|
|
|
|
post_revision = PostRevision.find_by(id: args[:post_revision_id])
|
2020-03-05 13:51:51 -05:00
|
|
|
return if post_revision.nil?
|
2019-05-08 03:18:56 -04:00
|
|
|
|
2019-05-08 03:58:08 -04:00
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
User.where(id: args[:user_ids]).find_each do |user|
|
2019-06-04 15:48:06 -04:00
|
|
|
next if post_revision.hidden && !user.staff?
|
|
|
|
|
2019-05-08 03:58:08 -04:00
|
|
|
PostActionNotifier.alerter.create_notification(
|
|
|
|
user,
|
|
|
|
Notification.types[:edited],
|
|
|
|
post_revision.post,
|
|
|
|
display_username: post_revision.user.username,
|
|
|
|
acting_user_id: post_revision&.user_id,
|
|
|
|
revision_number: post_revision.number
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2019-05-08 03:18:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|