mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Improve push notification message for watching_category_or_tag notifications (#24228)
This commit is contained in:
committed by
GitHub
parent
c5e6e271a5
commit
047cae4b3f
@@ -20,14 +20,7 @@ class PushNotificationPusher
|
||||
ActionController::Base.helpers.image_url("push-notifications/#{notification_icon_name}.png")
|
||||
|
||||
message = {
|
||||
title:
|
||||
payload[:translated_title] ||
|
||||
I18n.t(
|
||||
"discourse_push_notifications.popup.#{Notification.types[payload[:notification_type]]}",
|
||||
site_title: SiteSetting.title,
|
||||
topic: payload[:topic_title],
|
||||
username: payload[:username],
|
||||
),
|
||||
title: payload[:translated_title] || title(payload),
|
||||
body: payload[:excerpt],
|
||||
badge: get_badge,
|
||||
icon: notification_icon,
|
||||
@@ -43,6 +36,27 @@ class PushNotificationPusher
|
||||
message
|
||||
end
|
||||
|
||||
def self.title(payload)
|
||||
translation_key =
|
||||
case payload[:notification_type]
|
||||
when Notification.types[:watching_category_or_tag]
|
||||
# For watching_category_or_tag, the notification could be for either a new post or new topic.
|
||||
# Instead of duplicating translations, we can rely on 'watching_first_post' for new topics,
|
||||
# and 'posted' for new posts.
|
||||
type = payload[:post_number] == 1 ? "watching_first_post" : "posted"
|
||||
"discourse_push_notifications.popup.#{type}"
|
||||
else
|
||||
"discourse_push_notifications.popup.#{Notification.types[payload[:notification_type]]}"
|
||||
end
|
||||
|
||||
I18n.t(
|
||||
translation_key,
|
||||
site_title: SiteSetting.title,
|
||||
topic: payload[:topic_title],
|
||||
username: payload[:username],
|
||||
)
|
||||
end
|
||||
|
||||
def self.subscriptions(user)
|
||||
user.push_subscriptions
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user