summaryrefslogtreecommitdiff
path: root/packages/sw/src/scripts/create-notification.ts
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2025-04-15 18:27:45 +0900
committersyuilo <4439005+syuilo@users.noreply.github.com>2025-04-15 18:27:45 +0900
commitfc6037af461412d914cd35a00fa004ad26d19c0f (patch)
tree8551e0789e2a68a8a3ce05e3253a32d0fbcc86c8 /packages/sw/src/scripts/create-notification.ts
parentdocs: バックアップとログアウトの設定クリアについて書... (diff)
downloadmisskey-fc6037af461412d914cd35a00fa004ad26d19c0f.tar.gz
misskey-fc6037af461412d914cd35a00fa004ad26d19c0f.tar.bz2
misskey-fc6037af461412d914cd35a00fa004ad26d19c0f.zip
enhance(backend): push notification for chat message
Resolve #15831
Diffstat (limited to 'packages/sw/src/scripts/create-notification.ts')
-rw-r--r--packages/sw/src/scripts/create-notification.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts
index 364328d4b0..77b3f88791 100644
--- a/packages/sw/src/scripts/create-notification.ts
+++ b/packages/sw/src/scripts/create-notification.ts
@@ -268,6 +268,24 @@ async function composeNotification(data: PushNotificationDataMap[keyof PushNotif
data,
renotify: true,
}];
+ case 'newChatMessage':
+ if (data.body.toRoom != null) {
+ return [`${data.body.toRoom.name}: ${getUserName(data.body.fromUser)}: ${data.body.text}`, {
+ icon: data.body.fromUser.avatarUrl,
+ badge: iconUrl('messages'),
+ tag: `chat:room:${data.body.toRoomId}`,
+ data,
+ renotify: true,
+ }];
+ } else {
+ return [`${getUserName(data.body.fromUser)}: ${data.body.text}`, {
+ icon: data.body.fromUser.avatarUrl,
+ badge: iconUrl('messages'),
+ tag: `chat:user:${data.body.fromUserId}`,
+ data,
+ renotify: true,
+ }];
+ }
default:
return null;
}