mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 17:17:32 +00: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:
parent
20a479ff7c
commit
7e04b15ad8
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue