summaryrefslogtreecommitdiff
path: root/packages/sw/src/scripts
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2023-02-28 19:55:31 +0900
committerGitHub <noreply@github.com>2023-02-28 19:55:31 +0900
commitffe3386e5be3c72d89213857a8edefb86242a546 (patch)
tree118cd9836d169f45973fce018ea328d61f23187d /packages/sw/src/scripts
parentenhance: Play の「ソースを表示」にシンタックスハイライト... (diff)
downloadsharkey-ffe3386e5be3c72d89213857a8edefb86242a546.tar.gz
sharkey-ffe3386e5be3c72d89213857a8edefb86242a546.tar.bz2
sharkey-ffe3386e5be3c72d89213857a8edefb86242a546.zip
fix(sw): プッシュ通知でカスタム絵文字リアクションを表示できるように (#10122)
* fix(sw): プッシュ通知でカスタム絵文字リアクションを表示できるように Fix #10117 /emoji/*.webpにbadgeモードを * ? * :v: * fix
Diffstat (limited to 'packages/sw/src/scripts')
-rw-r--r--packages/sw/src/scripts/create-notification.ts26
1 files changed, 6 insertions, 20 deletions
diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts
index da92b37d19..6286d076c7 100644
--- a/packages/sw/src/scripts/create-notification.ts
+++ b/packages/sw/src/scripts/create-notification.ts
@@ -138,26 +138,11 @@ async function composeNotification(data: pushNotificationDataMap[keyof pushNotif
if (reaction.startsWith(':')) {
// カスタム絵文字の場合
- const customEmoji = data.body.note.emojis.find(x => x.name === reaction.substr(1, reaction.length - 2));
- if (customEmoji) {
- if (reaction.includes('@')) {
- reaction = `:${reaction.substr(1, reaction.indexOf('@') - 1)}:`;
- }
-
- const u = new URL(customEmoji.url);
- if (u.href.startsWith(`${origin}/proxy/`)) {
- // もう既にproxyっぽそうだったらsearchParams付けるだけ
- u.searchParams.set('badge', '1');
- badge = u.href;
- } else {
- // 拡張子がないとキャッシュしてくれないCDNがあるので
- const dummy = `${encodeURIComponent(`${u.host}${u.pathname}`)}.png`;
- badge = `${origin}/proxy/${dummy}?${url.query({
- url: u.href,
- badge: '1',
- })}`;
- }
- }
+ const name = reaction.substring(1, reaction.length - 1);
+ badge = `${origin}/emoji/${name}.webp?${url.query({
+ badge: '1',
+ })}`;
+ reaction = name.split('@')[0];
} else {
// Unicode絵文字の場合
badge = `/twemoji-badge/${char2fileName(reaction)}.png`;
@@ -171,6 +156,7 @@ async function composeNotification(data: pushNotificationDataMap[keyof pushNotif
return [`${reaction} ${getUserName(data.body.user)}`, {
body: data.body.note.text ?? '',
icon: data.body.user.avatarUrl,
+ tag,
badge,
data,
actions: [