A platform for community discussion. Free, open, simple.
FIX: On tag change notify only users watching the tag. (#7707)
Bianca Nenciu934adb14d247
diff --git a/app/jobs/regular/notify_tag_change.rb b/app/jobs/regular/notify_tag_change.rbindex 4e16d4eb6a5..370227eef70 100644--- a/app/jobs/regular/notify_tag_change.rb+++ b/app/jobs/regular/notify_tag_change.rb@@ -9,7 +9,6 @@ module Jobsif post&.topic&.visible?post_alerter = PostAlerter.new- post_alerter.notify_post_users(post, User.where(id: args[:notified_user_ids]))post_alerter.notify_first_post_watchers(post, post_alerter.tag_watchers(post.topic))endenddiff --git a/lib/post_revisor.rb b/lib/post_revisor.rbindex 7264fe24286..eaa00090e13 100644--- a/lib/post_revisor.rb+++ b/lib/post_revisor.rb@@ -94,8 +94,7 @@ class PostRevisortc.record_change('tags', prev_tags, tags)DB.after_commit dopost = 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)+ Jobs.enqueue(:notify_tag_change, post_id: post.id)endendenddiff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rbindex 1539025c958..8db8dc02a7e 100644--- a/spec/services/post_alerter_spec.rb+++ b/spec/services/post_alerter_spec.rb@@ -989,15 +989,16 @@ describe PostAlerter doSiteSetting.tagging_enabled = trueJobs.run_immediately!TagUser.change(user.id, watched_tag.id, TagUser.notification_levels[:watching_first_post])+ TopicUser.change(Fabricate(:user).id, post.topic.id, notification_level: TopicUser.notification_levels[:watching])endit "triggers a notification" doexpect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(0)- PostRevisor.new(post).revise!(Fabricate(:user), tags: [other_tag.name, watched_tag.name])+ expect { PostRevisor.new(post).revise!(Fabricate(:user), tags: [other_tag.name, watched_tag.name]) }.to change { Notification.count }.by(1)expect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(1)- PostRevisor.new(post).revise!(Fabricate(:user), tags: [watched_tag.name, other_tag.name])+ expect { PostRevisor.new(post).revise!(Fabricate(:user), tags: [watched_tag.name, other_tag.name]) }.to change { Notification.count }.by(0)expect(user.notifications.where(notification_type: Notification.types[:watching_first_post]).count).to eq(1)end