diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-11-02 15:57:55 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-11-02 15:57:55 +0900 |
| commit | f62ad3ed3eccfd242b2d1f1e25f00276f2bfff77 (patch) | |
| tree | 4c7280ec000d49ae69f31b97fb1043d20c3de0f1 /packages/backend/src/core/NotificationService.ts | |
| parent | fix(frontend): /about の連合タブのレイアウトが一部崩れてい... (diff) | |
| download | sharkey-f62ad3ed3eccfd242b2d1f1e25f00276f2bfff77.tar.gz sharkey-f62ad3ed3eccfd242b2d1f1e25f00276f2bfff77.tar.bz2 sharkey-f62ad3ed3eccfd242b2d1f1e25f00276f2bfff77.zip | |
feat: notification grouping
Resolve #12211
Diffstat (limited to 'packages/backend/src/core/NotificationService.ts')
| -rw-r--r-- | packages/backend/src/core/NotificationService.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts index 7c3672c67a..ad7be83e5b 100644 --- a/packages/backend/src/core/NotificationService.ts +++ b/packages/backend/src/core/NotificationService.ts @@ -19,6 +19,7 @@ import { IdService } from '@/core/IdService.js'; import { CacheService } from '@/core/CacheService.js'; import type { Config } from '@/config.js'; import { UserListService } from '@/core/UserListService.js'; +import type { FilterUnionByProperty } from '@/types.js'; @Injectable() export class NotificationService implements OnApplicationShutdown { @@ -73,10 +74,10 @@ export class NotificationService implements OnApplicationShutdown { } @bindThis - public async createNotification( + public async createNotification<T extends MiNotification['type']>( notifieeId: MiUser['id'], - type: MiNotification['type'], - data: Omit<Partial<MiNotification>, 'notifierId'>, + type: T, + data: Omit<FilterUnionByProperty<MiNotification, 'type', T>, 'type' | 'id' | 'createdAt' | 'notifierId'>, notifierId?: MiUser['id'] | null, ): Promise<MiNotification | null> { const profile = await this.cacheService.userProfileCache.fetch(notifieeId); @@ -128,9 +129,11 @@ export class NotificationService implements OnApplicationShutdown { id: this.idService.gen(), createdAt: new Date(), type: type, - notifierId: notifierId, + ...(notifierId ? { + notifierId, + } : {}), ...data, - } as MiNotification; + } as any as FilterUnionByProperty<MiNotification, 'type', T>; const redisIdPromise = this.redisClient.xadd( `notificationTimeline:${notifieeId}`, |