mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: new pm notification should take precedence over mention (#19391)
When a new private message is created with mention inside, notification about private message should take precedence over mention notification. https://meta.discourse.org/t/notification-badge-for-pm-mentioning-you/232950
This commit is contained in:
committed by
GitHub
parent
dabe7b6ea0
commit
f449113c8b
@@ -126,6 +126,7 @@ class PostAlerter
|
||||
|
||||
if mentioned_users
|
||||
mentioned_users = only_allowed_users(mentioned_users, post)
|
||||
mentioned_users = mentioned_users - pm_watching_users(post)
|
||||
notified += notify_users(mentioned_users - notified, :mentioned, post, mentioned_opts)
|
||||
end
|
||||
|
||||
@@ -642,6 +643,14 @@ class PostAlerter
|
||||
users
|
||||
end
|
||||
|
||||
def pm_watching_users(post)
|
||||
return [] if !post.topic.private_message?
|
||||
directly_targeted_users(post).filter do |u|
|
||||
notification_level = TopicUser.get(post.topic, u)&.notification_level
|
||||
notification_level == TopicUser.notification_levels[:watching]
|
||||
end
|
||||
end
|
||||
|
||||
def notify_pm_users(post, reply_to_user, quoted_users, notified)
|
||||
return [] unless post.topic
|
||||
|
||||
@@ -660,8 +669,7 @@ class PostAlerter
|
||||
users = directly_targeted_users(post).reject { |u| notified.include?(u) }
|
||||
DiscourseEvent.trigger(:before_create_notifications_for_users, users, post)
|
||||
users.each do |user|
|
||||
notification_level = TopicUser.get(post.topic, user)&.notification_level
|
||||
if reply_to_user == user || notification_level == TopicUser.notification_levels[:watching] || user.staged?
|
||||
if reply_to_user == user || pm_watching_users(post).include?(user) || user.staged?
|
||||
create_notification(user, Notification.types[:private_message], post, skip_send_email_to: emails_to_skip_send)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user