summaryrefslogtreecommitdiff
path: root/packages/sw/src/scripts/create-notification.ts
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2023-04-11 14:11:39 +0900
committerGitHub <noreply@github.com>2023-04-11 14:11:39 +0900
commit3a90bcc03cc166632fb64aa76130b63a0ad37a64 (patch)
treee5e6e6e07eb30d1369142d86546b6ab419d31a1b /packages/sw/src/scripts/create-notification.ts
parentfix #10554 チャンネルの検索用ページとAPIの追加 (#10555) (diff)
downloadsharkey-3a90bcc03cc166632fb64aa76130b63a0ad37a64.tar.gz
sharkey-3a90bcc03cc166632fb64aa76130b63a0ad37a64.tar.bz2
sharkey-3a90bcc03cc166632fb64aa76130b63a0ad37a64.zip
sw: なんかもうめっちゃ変えた (#10570)
* sw: なんかいろいろ * remove debug code * never renotify * update changelog.md
Diffstat (limited to 'packages/sw/src/scripts/create-notification.ts')
-rw-r--r--packages/sw/src/scripts/create-notification.ts34
1 files changed, 23 insertions, 11 deletions
diff --git a/packages/sw/src/scripts/create-notification.ts b/packages/sw/src/scripts/create-notification.ts
index 8e214c9850..4d27858253 100644
--- a/packages/sw/src/scripts/create-notification.ts
+++ b/packages/sw/src/scripts/create-notification.ts
@@ -21,7 +21,7 @@ const iconUrl = (name: BadgeNames) => `/static-assets/tabler-badges/${name}.png`
* 1. Find the icon and download png from https://tabler-icons.io/
* 2. vips resize ~/Downloads/icon-name.png vipswork.png 0.4; vips scRGB2BW vipswork.png ~/icon-name.png"[compression=9,strip]"; rm vipswork.png;
* 3. mv ~/icon-name.png ~/misskey/packages/backend/assets/tabler-badges/
- * 4. Add 'icon-name' to badgeNames
+ * 4. Add 'icon-name' to BadgeNames
* 5. Add `badge: iconUrl('icon-name'),`
*/
@@ -168,14 +168,6 @@ async function composeNotification(data: PushNotificationDataMap[keyof PushNotif
}];
}
- case 'pollEnded':
- return [t('_notification.pollEnded'), {
- body: data.body.note.text || '',
- badge: iconUrl('chart-arrows'),
- tag: `poll:${data.body.note.id}`,
- data,
- }];
-
case 'receiveFollowRequest':
return [t('_notification.youReceivedFollowRequest'), {
body: getUserName(data.body.user),
@@ -202,6 +194,14 @@ async function composeNotification(data: PushNotificationDataMap[keyof PushNotif
data,
}];
+ case 'achievementEarned':
+ return [t('_notification.achievementEarned'), {
+ body: t(`_achievements._types._${data.body.achievement}.title`),
+ badge: iconUrl('medal'),
+ data,
+ tag: `achievement:${data.body.achievement}`,
+ }];
+
case 'app':
return [data.body.header ?? data.body.body, {
body: data.body.header ? data.body.body : '',
@@ -233,17 +233,29 @@ export async function createEmptyNotification() {
const { t } = i18n;
await globalThis.registration.showNotification(
- t('_notification.emptyPushNotificationMessage'),
+ (new URL(origin)).host,
{
+ body: `Misskey v${_VERSION_}`,
silent: true,
badge: iconUrl('null'),
tag: 'read_notification',
+ actions: [
+ {
+ action: 'markAllAsRead',
+ title: t('markAllAsRead'),
+ },
+ {
+ action: 'settings',
+ title: t('notificationSettings'),
+ },
+ ],
+ data: {},
},
);
setTimeout(async () => {
try {
- await closeNotificationsByTags(['user_visible_auto_notification', 'read_notification']);
+ await closeNotificationsByTags(['user_visible_auto_notification']);
} finally {
res();
}