diff --git a/plugins/chat/lib/chat/notifier.rb b/plugins/chat/lib/chat/notifier.rb index 84c151e3ecf..e0d0c0abd00 100644 --- a/plugins/chat/lib/chat/notifier.rb +++ b/plugins/chat/lib/chat/notifier.rb @@ -89,13 +89,14 @@ module Chat .pluck(:user_id) to_notify = list_users_to_notify - needs_notification_ids = to_notify[:all_mentioned_user_ids] - already_notified_user_ids + mentioned_user_ids = to_notify.extract!(:all_mentioned_user_ids)[:all_mentioned_user_ids] + needs_notification_ids = mentioned_user_ids - already_notified_user_ids return if needs_notification_ids.blank? notify_creator_of_inaccessible_mentions(to_notify) notify_mentioned_users(to_notify, already_notified_user_ids: already_notified_user_ids) - to_notify.except(:all_mentioned_user_ids) + to_notify end private diff --git a/plugins/chat/spec/lib/chat/notifier_spec.rb b/plugins/chat/spec/lib/chat/notifier_spec.rb index 9c55e86bf3a..48ee215777c 100644 --- a/plugins/chat/spec/lib/chat/notifier_spec.rb +++ b/plugins/chat/spec/lib/chat/notifier_spec.rb @@ -124,7 +124,8 @@ describe Chat::Notifier do describe "editing a direct mention into a global mention" do let(:mention) { "hello @#{user_2.username}!" } - it "doesn't return :all_mentioned_user_ids" do + it "doesn't send notifications with :all_mentioned_user_ids as an identifier" do + Jobs.run_immediately! msg = build_cooked_msg(mention, user_1) Chat::MessageUpdater.update( @@ -133,8 +134,12 @@ describe Chat::Notifier do new_content: "hello @all", ) - to_notify = described_class.new(msg, msg.created_at).notify_edit - expect(to_notify[:all_mentioned_user_ids]).not_to be_present + described_class.new(msg, msg.created_at).notify_edit + + notifications = Notification.where(user: user_2) + notifications.each do |notification| + expect(notification.data).not_to include("\"identifier\":\"all_mentioned_user_ids\"") + end end end