diff options
author | Elizabeth Martín Campos <me@elizabeth.sh> | 2023-02-03 09:29:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-03 09:29:32 +0100 |
commit | 7e04b15ad8bde9b22e7a3bb717e3d6177d3fa430 (patch) | |
tree | 539d1f098c9eb8bbadd51e0dcb501a3176398c03 | |
parent | 20a479ff7c3bcd8e5c223dae53b30b174d87f1bf (diff) |
fix(web-push-notifications): fix favourite push notifications (#23286)
Fix a bug where clicking in a favourite push notification would result in a 404 (not found) error, since we were redirecting the user to the wrong URL (we were redirecting to /@<user who favourited>/<favourited status id>, when it should be /@<favourited status author>/<favourited status id>)
-rw-r--r-- | app/javascript/mastodon/service_worker/web_push_notifications.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/javascript/mastodon/service_worker/web_push_notifications.js b/app/javascript/mastodon/service_worker/web_push_notifications.js index f12595777..b9d626694 100644 --- a/app/javascript/mastodon/service_worker/web_push_notifications.js +++ b/app/javascript/mastodon/service_worker/web_push_notifications.js @@ -1,6 +1,6 @@ import IntlMessageFormat from 'intl-messageformat'; -import locales from './web_push_locales'; import { unescape } from 'lodash'; +import locales from './web_push_locales'; const MAX_NOTIFICATIONS = 5; const GROUP_TAG = 'tag'; @@ -90,7 +90,13 @@ export const handlePush = (event) => { options.tag = notification.id; options.badge = '/badge.png'; options.image = notification.status && notification.status.media_attachments.length > 0 && notification.status.media_attachments[0].preview_url || undefined; - options.data = { access_token, preferred_locale, id: notification.status ? notification.status.id : notification.account.id, url: notification.status ? `/@${notification.account.acct}/${notification.status.id}` : `/@${notification.account.acct}` }; + options.data = { access_token, preferred_locale, id: notification.status ? notification.status.id : notification.account.id }; + + if (notification.status) { + options.data.url = `/@${notification.status.account.acct}/${notification.status.id}`; + } else { + options.data.url = `/@${notification.account.acct}`; + } if (notification.status && notification.status.spoiler_text || notification.status.sensitive) { options.data.hiddenBody = htmlToPlainText(notification.status.content); |