FIX: Skip job if tag edit notification is disabled (#17508)
Previous commit did not schedule any more new jobs, but the jobs in
queue could still create notifications.
Follow up to commit e8d802eb86
.
This commit is contained in:
parent
f774083016
commit
4a996825fd
|
@ -3,6 +3,8 @@
|
|||
module Jobs
|
||||
class NotifyTagChange < ::Jobs::Base
|
||||
def execute(args)
|
||||
return if SiteSetting.disable_tags_edit_notifications
|
||||
|
||||
post = Post.find_by(id: args[:post_id])
|
||||
|
||||
if post&.topic&.visible?
|
||||
|
|
|
@ -113,7 +113,14 @@ class PostRevisor
|
|||
DB.after_commit do
|
||||
post = tc.topic.ordered_posts.first
|
||||
notified_user_ids = [post.user_id, post.last_editor_id].uniq
|
||||
Jobs.enqueue(:notify_tag_change, post_id: post.id, notified_user_ids: notified_user_ids, diff_tags: ((tags - prev_tags) | (prev_tags - tags))) if !SiteSetting.disable_tags_edit_notifications
|
||||
if !SiteSetting.disable_tags_edit_notifications
|
||||
Jobs.enqueue(
|
||||
:notify_tag_change,
|
||||
post_id: post.id,
|
||||
notified_user_ids: notified_user_ids,
|
||||
diff_tags: ((tags - prev_tags) | (prev_tags - tags))
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,22 @@ describe ::Jobs::NotifyTagChange do
|
|||
expect(notification.notification_type).to eq(Notification.types[:posted])
|
||||
end
|
||||
|
||||
it "doesn't create notifications if tags edit notifications are disabled" do
|
||||
SiteSetting.disable_tags_edit_notifications = true
|
||||
|
||||
TagUser.create!(
|
||||
user_id: user.id,
|
||||
tag_id: tag.id,
|
||||
notification_level: NotificationLevels.topic_levels[:watching]
|
||||
)
|
||||
TopicTag.create!(
|
||||
topic_id: post.topic.id,
|
||||
tag_id: tag.id
|
||||
)
|
||||
|
||||
expect { described_class.new.execute(post_id: post.id, notified_user_ids: [regular_user.id]) }.not_to change { Notification.count }
|
||||
end
|
||||
|
||||
it 'doesnt create notification for user watching category' do
|
||||
CategoryUser.create!(
|
||||
user_id: user.id,
|
||||
|
|
Loading…
Reference in New Issue