1
0
mirror of https://github.com/funamitech/mastodon synced 2024-11-28 14:58:38 +09:00

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>)
This commit is contained in:
Elizabeth Martín Campos 2023-02-03 09:29:32 +01:00 committed by GitHub
parent 20a479ff7c
commit 7e04b15ad8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import IntlMessageFormat from 'intl-messageformat'; import IntlMessageFormat from 'intl-messageformat';
import locales from './web_push_locales';
import { unescape } from 'lodash'; import { unescape } from 'lodash';
import locales from './web_push_locales';
const MAX_NOTIFICATIONS = 5; const MAX_NOTIFICATIONS = 5;
const GROUP_TAG = 'tag'; const GROUP_TAG = 'tag';
@ -90,7 +90,13 @@ export const handlePush = (event) => {
options.tag = notification.id; options.tag = notification.id;
options.badge = '/badge.png'; options.badge = '/badge.png';
options.image = notification.status && notification.status.media_attachments.length > 0 && notification.status.media_attachments[0].preview_url || undefined; 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) { if (notification.status && notification.status.spoiler_text || notification.status.sensitive) {
options.data.hiddenBody = htmlToPlainText(notification.status.content); options.data.hiddenBody = htmlToPlainText(notification.status.content);