mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
FIX: Don't notify editor when category or tag change (#17833)
When a user was editing a topic they were also receiving a notification if they were watching any of the new category or tags.
This commit is contained in:
parent
e87ca397be
commit
2db076f9c8
|
@ -203,8 +203,8 @@ class PostAlerter
|
||||||
|
|
||||||
warn_if_not_sidekiq
|
warn_if_not_sidekiq
|
||||||
|
|
||||||
# Don't notify the OP
|
# Don't notify the OP and last editor
|
||||||
user_ids -= [post.user_id]
|
user_ids -= [post.user_id, post.last_editor_id]
|
||||||
users = User.where(id: user_ids).includes(:do_not_disturb_timings)
|
users = User.where(id: user_ids).includes(:do_not_disturb_timings)
|
||||||
|
|
||||||
DiscourseEvent.trigger(:before_create_notifications_for_users, users, post)
|
DiscourseEvent.trigger(:before_create_notifications_for_users, users, post)
|
||||||
|
|
16
spec/jobs/notify_category_change_spec.rb
Normal file
16
spec/jobs/notify_category_change_spec.rb
Normal file
|
@ -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
|
|
@ -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 }
|
expect { described_class.new.execute(post_id: post.id, notified_user_ids: [regular_user.id]) }.not_to change { Notification.count }
|
||||||
end
|
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
|
it 'doesnt create notification for user watching category' do
|
||||||
CategoryUser.create!(
|
CategoryUser.create!(
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user