A platform for community discussion. Free, open, simple.
FIX: mention notification takes precedence over group (#12407)
Krzysztof Kotlarek146775072a11
diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rbindex eb5f5bbf384..fc6c74bed88 100644--- a/app/services/post_alerter.rb+++ b/app/services/post_alerter.rb@@ -70,15 +70,15 @@ class PostAlertermentioned_opts = { user_id: editor.id, original_username: editor.username, display_username: editor.username }end- expand_group_mentions(mentioned_groups, post) do |group, users|- users = only_allowed_users(users, post)- notified += notify_users(users - notified, :group_mentioned, post, mentioned_opts.merge(group: group))- end-if mentioned_usersmentioned_users = only_allowed_users(mentioned_users, post)notified += notify_users(mentioned_users - notified, :mentioned, post, mentioned_opts)end++ expand_group_mentions(mentioned_groups, post) do |group, users|+ users = only_allowed_users(users, post)+ notified += notify_users(users - notified, :group_mentioned, post, mentioned_opts.merge(group: group))+ endend# repliesdiff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rbindex c70d47815f0..8d492c14b73 100644--- a/spec/services/post_alerter_spec.rb+++ b/spec/services/post_alerter_spec.rb@@ -380,6 +380,13 @@ describe PostAlerter doexpect(GroupMention.count).to eq(4)end+ it 'takes private mention as precedence' do+ expect {+ create_post_with_alerts(raw: "Hello @group and @eviltrout, nice to meet you")+ }.to change(evil_trout.notifications, :count).by(1)+ expect(evil_trout.notifications.last.notification_type).to eq(Notification.types[:mentioned])+ end+it "triggers :before_create_notifications_for_users" doevents = DiscourseEvent.track_events dopost