mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Revert "FIX: prevent double notifications when replying to a group message"
This reverts commit e82dc21083
.
This commit is contained in:
parent
650c2f271e
commit
e53f110c83
@ -17,9 +17,18 @@ class PostAlerter
|
|||||||
def after_save_post(post, new_record = false)
|
def after_save_post(post, new_record = false)
|
||||||
notified = [post.user].compact
|
notified = [post.user].compact
|
||||||
|
|
||||||
if new_record && post.topic.private_message? && (post.is_first_post? || post.post_type == Post.types[:moderator_action])
|
if new_record && post.topic.private_message?
|
||||||
# If it's a private message, notify the topic_allowed_users
|
# If it's a private message, notify the topic_allowed_users
|
||||||
allowed_users(post).each do |user|
|
allowed_users(post).each do |user|
|
||||||
|
case TopicUser.get(post.topic, user).try(:notification_level)
|
||||||
|
when TopicUser.notification_levels[:tracking]
|
||||||
|
next unless post.reply_to_post_number || post.reply_to_post.try(:user_id) == user.id
|
||||||
|
when TopicUser.notification_levels[:regular]
|
||||||
|
next unless post.reply_to_post.try(:user_id) == user.id
|
||||||
|
when TopicUser.notification_levels[:muted]
|
||||||
|
notified += [user]
|
||||||
|
next
|
||||||
|
end
|
||||||
create_notification(user, Notification.types[:private_message], post)
|
create_notification(user, Notification.types[:private_message], post)
|
||||||
notified += [user]
|
notified += [user]
|
||||||
end
|
end
|
||||||
@ -31,7 +40,9 @@ class PostAlerter
|
|||||||
notify_users(reply_to_user, :replied, post)
|
notify_users(reply_to_user, :replied, post)
|
||||||
end
|
end
|
||||||
|
|
||||||
notified += [reply_to_user] if reply_to_user
|
if reply_to_user
|
||||||
|
notified += [reply_to_user]
|
||||||
|
end
|
||||||
|
|
||||||
mentioned_groups, mentioned_users = extract_mentions(post)
|
mentioned_groups, mentioned_users = extract_mentions(post)
|
||||||
|
|
||||||
@ -134,20 +145,21 @@ class PostAlerter
|
|||||||
|
|
||||||
# Don't notify the same user about the same notification on the same post
|
# Don't notify the same user about the same notification on the same post
|
||||||
existing_notification = user.notifications
|
existing_notification = user.notifications
|
||||||
.order("notifications.id DESC")
|
.order("notifications.id desc")
|
||||||
.find_by(topic_id: post.topic_id,
|
.find_by(topic_id: post.topic_id,
|
||||||
post_number: post.post_number,
|
post_number: post.post_number,
|
||||||
notification_type: type)
|
notification_type: type)
|
||||||
|
|
||||||
if existing_notification
|
if existing_notification && existing_notification.notification_type == type
|
||||||
return unless type == Notification.types[:edited] && existing_notification.data_hash["display_username"] == opts[:display_username]
|
return unless existing_notification.notification_type == Notification.types[:edited] &&
|
||||||
|
existing_notification.data_hash["display_username"] = opts[:display_username]
|
||||||
end
|
end
|
||||||
|
|
||||||
collapsed = false
|
collapsed = false
|
||||||
|
|
||||||
if type == Notification.types[:replied] || type == Notification.types[:posted]
|
if type == Notification.types[:replied] || type == Notification.types[:posted]
|
||||||
destroy_notifications(user, Notification.types[:replied], post.topic)
|
destroy_notifications(user, Notification.types[:replied] , post.topic)
|
||||||
destroy_notifications(user, Notification.types[:posted], post.topic)
|
destroy_notifications(user, Notification.types[:posted] , post.topic)
|
||||||
collapsed = true
|
collapsed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user