mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 17:06:31 -06:00
FIX: On tag change notify only users watching the tag. (#7707)
This commit is contained in:
parent
1881e895dc
commit
934adb14d2
@ -9,7 +9,6 @@ module Jobs
|
||||
|
||||
if 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))
|
||||
end
|
||||
end
|
||||
|
@ -94,8 +94,7 @@ class PostRevisor
|
||||
tc.record_change('tags', prev_tags, tags)
|
||||
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)
|
||||
Jobs.enqueue(:notify_tag_change, post_id: post.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -989,15 +989,16 @@ describe PostAlerter do
|
||||
SiteSetting.tagging_enabled = true
|
||||
Jobs.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])
|
||||
end
|
||||
|
||||
it "triggers a notification" do
|
||||
expect(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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user