FIX: collapse 'replied', 'quoted' and 'posted' to the same notification

This commit is contained in:
Régis Hanol 2016-03-07 21:56:33 +01:00
parent df413737d2
commit 74e4251aff

View file

@ -208,15 +208,19 @@ class PostAlerter
end end
def should_notify_previous?(user, notification, opts) def should_notify_previous?(user, notification, opts)
type = notification.notification_type case notification.notification_type
if type == Notification.types[:edited] when Notification.types[:edited] then should_notify_edit?(notification, opts)
return should_notify_edit?(notification, opts) when Notification.types[:liked] then should_notify_like?(user, notification)
elsif type == Notification.types[:liked] else false
return should_notify_like?(user, notification)
end end
return false
end end
COLLAPSED_NOTIFICATION_TYPES ||= [
Notification.types[:replied],
Notification.types[:quoted],
Notification.types[:posted],
]
def create_notification(user, type, post, opts=nil) def create_notification(user, type, post, opts=nil)
return if user.blank? return if user.blank?
return if user.id == Discourse::SYSTEM_USER_ID return if user.id == Discourse::SYSTEM_USER_ID
@ -268,9 +272,10 @@ class PostAlerter
collapsed = false collapsed = false
if type == Notification.types[:replied] || type == Notification.types[:posted] if COLLAPSED_NOTIFICATION_TYPES.include?(type)
destroy_notifications(user, Notification.types[:replied], post.topic) COLLAPSED_NOTIFICATION_TYPES.each do |t|
destroy_notifications(user, Notification.types[:posted], post.topic) destroy_notifications(user, t, post.topic)
end
collapsed = true collapsed = true
end end