A platform for community discussion. Free, open, simple.
DEV: Support translated title in desktop/notifications (#14325)
Mark VanLandingham68bb7c5a66d9
diff --git a/app/assets/javascripts/discourse/app/lib/desktop-notifications.js b/app/assets/javascripts/discourse/app/lib/desktop-notifications.jsindex 5e6053b43bc..bbc48991478 100644--- a/app/assets/javascripts/discourse/app/lib/desktop-notifications.js+++ b/app/assets/javascripts/discourse/app/lib/desktop-notifications.js@@ -153,11 +153,13 @@ function onNotification(data, siteSettings, user) {return;}- const notificationTitle = I18n.t(i18nKey(data.notification_type), {- site_title: siteSettings.title,- topic: data.topic_title,- username: formatUsername(data.username),- });+ const notificationTitle =+ data.translated_title ||+ I18n.t(i18nKey(data.notification_type), {+ site_title: siteSettings.title,+ topic: data.topic_title,+ username: formatUsername(data.username),+ });const notificationBody = data.excerpt;diff --git a/app/models/notification.rb b/app/models/notification.rbindex a22be0e901c..bf91b350c2b 100644--- a/app/models/notification.rb+++ b/app/models/notification.rb@@ -75,7 +75,8 @@ class Notification < ActiveRecord::BaseDB.exec(<<~SQL)DELETEFROM notifications n- WHERE high_priority AND notification_type <> #{types[:chat_mention].to_i}+ WHERE high_priority+ AND notification_type NOT IN (#{types[:chat_mention].to_i}, #{types[:chat_message].to_i})AND NOT EXISTS (SELECT 1FROM posts p@@ -117,7 +118,8 @@ class Notification < ActiveRecord::Basevotes_released: 26,event_reminder: 27,event_invitation: 28,- chat_mention: 29+ chat_mention: 29,+ chat_message: 30,)enddiff --git a/app/services/push_notification_pusher.rb b/app/services/push_notification_pusher.rbindex 33872d599ae..3e0e4dc08a3 100644--- a/app/services/push_notification_pusher.rb+++ b/app/services/push_notification_pusher.rb@@ -7,7 +7,7 @@ class PushNotificationPusherdef self.push(user, payload)I18n.with_locale(user.effective_locale) domessage = {- title: I18n.t(+ title: payload[:translated_title] || I18n.t("discourse_push_notifications.popup.#{Notification.types[payload[:notification_type]]}",site_title: SiteSetting.title,topic: payload[:topic_title],diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rbindex e609a6063c0..9afd1d86513 100644--- a/spec/models/notification_spec.rb+++ b/spec/models/notification_spec.rb@@ -48,6 +48,8 @@ describe Notification doexpect(@types[:votes_released]).to eq(26)expect(@types[:event_reminder]).to eq(27)expect(@types[:event_invitation]).to eq(28)+ expect(@types[:chat_mention]).to eq(29)+ expect(@types[:chat_message]).to eq(30)endendenddiff --git a/spec/requests/api/schemas/json/site_response.json b/spec/requests/api/schemas/json/site_response.jsonindex 2781ff62d53..bda5dad96a4 100644--- a/spec/requests/api/schemas/json/site_response.json+++ b/spec/requests/api/schemas/json/site_response.json@@ -94,6 +94,9 @@},"chat_mention": {"type": "integer"+ },+ "chat_message": {+ "type": "integer"}},"required": [