A platform for community discussion. Free, open, simple.
FIX: ensures `all_mentioned_user_ids` is not used as identifier (#21491)
Andrei Prigorshnevb85d057df4e4
diff --git a/plugins/chat/lib/chat/notifier.rb b/plugins/chat/lib/chat/notifier.rbindex 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_idsreturn 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_notifyendprivatediff --git a/plugins/chat/spec/lib/chat/notifier_spec.rb b/plugins/chat/spec/lib/chat/notifier_spec.rbindex 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 dodescribe "editing a direct mention into a global mention" dolet(: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 donew_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\"")+ endendend