From 16e530f29544e2a95294ad441ff6f93d65160c7f Mon Sep 17 00:00:00 2001 From: ibuki2003 Date: Sun, 24 Sep 2023 19:29:19 +0900 Subject: [PATCH] feat: support post notification post notification is added at misskey 2023.9.0 --- src/locales/en.ts | 1 + src/locales/ja.ts | 1 + src/misskeyNotifications.ts | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/src/locales/en.ts b/src/locales/en.ts index cefe995..8663965 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -43,6 +43,7 @@ const en: Locale = { receiveFollowRequest: `{{userName}} sent you a follow request`, pollEnded: "The poll has ended", achievementEarned: "You earned an achievement", + newNoteByUser: "{{userName}} posted a note", }, settings: { diff --git a/src/locales/ja.ts b/src/locales/ja.ts index 9d40731..0c82f37 100644 --- a/src/locales/ja.ts +++ b/src/locales/ja.ts @@ -41,6 +41,7 @@ const ja = { receiveFollowRequest: `{{userName}} からフォローリクエストが届きました`, pollEnded: "アンケートの結果が出ました", achievementEarned: "実績を解除しました", + newNoteByUser: "{{userName}} がノートしました", }, settings: { diff --git a/src/misskeyNotifications.ts b/src/misskeyNotifications.ts index d1a2c2f..d1dc7f8 100644 --- a/src/misskeyNotifications.ts +++ b/src/misskeyNotifications.ts @@ -4,7 +4,16 @@ import { entities } from "misskey-js"; // to avoid type error; real notification may be different from document type RealNotification = | entities.Notification + // TODO: update misskey-js and remove these lines after the next release + // pollEnded notification will be added in the next release of misskey-js | { type: "pollEnded"; note: entities.Note } + // note notification will be added in the next release of misskey + | { + type: "note"; + user: entities.User; + userId: entities.User["id"]; + note: entities.Note; + } | { type: "achievementEarned"; achievement: string }; export interface NotificationContent { @@ -192,6 +201,14 @@ export function composeNotification( badgeUrl: getMkStaticIcon(srcDomain, "medal"), }; + case "note": + return { + title: i18n.t("notifications.newNoteByUser", { + userName: notif.user.name ?? notif.user.username, + }), + body: notif.note.text ?? "", + }; + default: return { // // @ts-expect-error real notification is different from document