diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index 53942b31d5..bd5ee865cf 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -203,8 +203,8 @@ class PostAlerter warn_if_not_sidekiq - # Don't notify the OP - user_ids -= [post.user_id] + # Don't notify the OP and last editor + user_ids -= [post.user_id, post.last_editor_id] users = User.where(id: user_ids).includes(:do_not_disturb_timings) DiscourseEvent.trigger(:before_create_notifications_for_users, users, post) diff --git a/spec/jobs/notify_category_change_spec.rb b/spec/jobs/notify_category_change_spec.rb new file mode 100644 index 0000000000..d218760aed --- /dev/null +++ b/spec/jobs/notify_category_change_spec.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +RSpec.describe ::Jobs::NotifyCategoryChange do + fab!(:user) { Fabricate(:user) } + fab!(:regular_user) { Fabricate(:trust_level_4) } + fab!(:post) { Fabricate(:post, user: regular_user) } + fab!(:category) { Fabricate(:category, name: 'test') } + + it "doesn't create notification for the editor who watches new tag" do + CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:watching_first_post], category.id) + post.topic.update!(category: category) + post.update!(last_editor_id: user.id) + + expect { described_class.new.execute(post_id: post.id, notified_user_ids: []) }.not_to change { Notification.count } + end +end diff --git a/spec/jobs/notify_tag_change_spec.rb b/spec/jobs/notify_tag_change_spec.rb index f0fab3d519..581fd0e251 100644 --- a/spec/jobs/notify_tag_change_spec.rb +++ b/spec/jobs/notify_tag_change_spec.rb @@ -40,6 +40,14 @@ RSpec.describe ::Jobs::NotifyTagChange do expect { described_class.new.execute(post_id: post.id, notified_user_ids: [regular_user.id]) }.not_to change { Notification.count } end + it "doesn't create notification for the editor who watches new tag" do + TagUser.change(user.id, tag.id, TagUser.notification_levels[:watching_first_post]) + TopicTag.create!(topic: post.topic, tag: tag) + post.update!(last_editor_id: user.id) + + expect { described_class.new.execute(post_id: post.id, notified_user_ids: []) }.not_to change { Notification.count } + end + it 'doesnt create notification for user watching category' do CategoryUser.create!( user_id: user.id,