Skip to content

Commit

Permalink
feat: support post notification
Browse files Browse the repository at this point in the history
post notification is added at misskey 2023.9.0
  • Loading branch information
ibuki2003 committed Sep 24, 2023
1 parent 7796129 commit 16e530f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ja = {
receiveFollowRequest: `{{userName}} からフォローリクエストが届きました`,
pollEnded: "アンケートの結果が出ました",
achievementEarned: "実績を解除しました",
newNoteByUser: "{{userName}} がノートしました",
},

settings: {
Expand Down
17 changes: 17 additions & 0 deletions src/misskeyNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 16e530f

Please sign in to comment.