mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-29 23:43:55 -04:00
FIX: collapse 'replied', 'quoted' and 'posted' to the same notification
This commit is contained in:
parent
df413737d2
commit
74e4251aff
1 changed files with 14 additions and 9 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue