summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/Notification.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-11-02 15:57:55 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-11-02 15:57:55 +0900
commitf62ad3ed3eccfd242b2d1f1e25f00276f2bfff77 (patch)
tree4c7280ec000d49ae69f31b97fb1043d20c3de0f1 /packages/backend/src/models/Notification.ts
parentfix(frontend): /about の連合タブのレイアウトが一部崩れてい... (diff)
downloadsharkey-f62ad3ed3eccfd242b2d1f1e25f00276f2bfff77.tar.gz
sharkey-f62ad3ed3eccfd242b2d1f1e25f00276f2bfff77.tar.bz2
sharkey-f62ad3ed3eccfd242b2d1f1e25f00276f2bfff77.zip
feat: notification grouping
Resolve #12211
Diffstat (limited to 'packages/backend/src/models/Notification.ts')
-rw-r--r--packages/backend/src/models/Notification.ts110
1 files changed, 87 insertions, 23 deletions
diff --git a/packages/backend/src/models/Notification.ts b/packages/backend/src/models/Notification.ts
index c0a9df2e23..1d5fc124e2 100644
--- a/packages/backend/src/models/Notification.ts
+++ b/packages/backend/src/models/Notification.ts
@@ -10,30 +10,73 @@ import { MiFollowRequest } from './FollowRequest.js';
import { MiAccessToken } from './AccessToken.js';
export type MiNotification = {
+ type: 'note';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+ noteId: MiNote['id'];
+} | {
+ type: 'follow';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+} | {
+ type: 'mention';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+ noteId: MiNote['id'];
+} | {
+ type: 'reply';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+ noteId: MiNote['id'];
+} | {
+ type: 'renote';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+ noteId: MiNote['id'];
+ targetNoteId: MiNote['id'];
+} | {
+ type: 'quote';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+ noteId: MiNote['id'];
+} | {
+ type: 'reaction';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+ noteId: MiNote['id'];
+ reaction: string;
+} | {
+ type: 'pollEnded';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+ noteId: MiNote['id'];
+} | {
+ type: 'receiveFollowRequest';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+} | {
+ type: 'followRequestAccepted';
+ id: string;
+ createdAt: string;
+ notifierId: MiUser['id'];
+} | {
+ type: 'achievementEarned';
+ id: string;
+ createdAt: string;
+ achievement: string;
+} | {
+ type: 'app';
id: string;
-
- // RedisのためDateではなくstring
createdAt: string;
-
- /**
- * 通知の送信者(initiator)
- */
- notifierId: MiUser['id'] | null;
-
- /**
- * 通知の種類。
- */
- type: typeof notificationTypes[number];
-
- noteId: MiNote['id'] | null;
-
- followRequestId: MiFollowRequest['id'] | null;
-
- reaction: string | null;
-
- choice: number | null;
-
- achievement: string | null;
/**
* アプリ通知のbody
@@ -56,4 +99,25 @@ export type MiNotification = {
* アプリ通知のアプリ(のトークン)
*/
appAccessTokenId: MiAccessToken['id'] | null;
-}
+} | {
+ type: 'test';
+ id: string;
+ createdAt: string;
+};
+
+export type MiGroupedNotification = MiNotification | {
+ type: 'reaction:grouped';
+ id: string;
+ createdAt: string;
+ noteId: MiNote['id'];
+ reactions: {
+ userId: string;
+ reaction: string;
+ }[];
+} | {
+ type: 'renote:grouped';
+ id: string;
+ createdAt: string;
+ noteId: MiNote['id'];
+ userIds: string[];
+};