]> cat aescling's git repositories - mastodon.git/commitdiff
fix(web_push_notifications): Send message with welcome notifications (#4471)
authorSorin Davidoi <sorin.davidoi@gmail.com>
Tue, 1 Aug 2017 04:00:13 +0000 (06:00 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 1 Aug 2017 04:00:13 +0000 (06:00 +0200)
* fix(web_push_notifications): Send grouping title in welcome notification

* fix(web_push_notifications): Read message from last notification

app/javascript/mastodon/service_worker/web_push_notifications.js
app/models/web/push_subscription.rb

index 64c4578894e8a27963b717b5097bcabe3ef4486f..acb85f6262bd979962c8e3f6eb6286b9fe01f947 100644 (file)
@@ -9,7 +9,7 @@ const notify = options =>
     if (notifications.length === MAX_NOTIFICATIONS) {
       // Reached the maximum number of notifications, proceed with grouping
       const group = {
-        title: formatGroupTitle(notifications[0].data.message, notifications.length + 1),
+        title: formatGroupTitle(options.data.message, notifications.length + 1),
         body: notifications
           .sort((n1, n2) => n1.timestamp < n2.timestamp)
           .map(notification => notification.title).join('\n'),
@@ -19,7 +19,7 @@ const notify = options =>
         data: {
           url: (new URL('/web/notifications', self.location)).href,
           count: notifications.length + 1,
-          message: notifications[0].data.message,
+          message: options.data.message,
         },
       };
 
index 45ce3298aa2bdcb280ee5e43bf3c1252015d49f1..e76f61278ef0b0e57c1012c50e3a13a54fe4b6ea 100644 (file)
@@ -161,6 +161,7 @@ class Web::PushSubscription < ApplicationRecord
           content: translate('push_notifications.subscribed.body'),
           actions: [],
           url: web_url('notifications'),
+          message: translate('push_notifications.group.title'), # Do not pass count, will be formatted in the ServiceWorker
         }
       ),
       endpoint: endpoint,