mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
FIX: mention notification takes precedence over group (#12407)
When a specific user is mentioned and group to which this user belongs, a direct mention notification should take precedence.
This commit is contained in:
parent
37c42a57b0
commit
146775072a
|
@ -70,15 +70,15 @@ class PostAlerter
|
|||
mentioned_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_users
|
||||
mentioned_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))
|
||||
end
|
||||
end
|
||||
|
||||
# replies
|
||||
|
|
|
@ -380,6 +380,13 @@ describe PostAlerter do
|
|||
expect(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" do
|
||||
events = DiscourseEvent.track_events do
|
||||
post
|
||||
|
|
Loading…
Reference in New Issue
Block a user