diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2024-03-01 21:17:01 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-01 21:17:01 +0900 |
| commit | 7e706ea6693781fb8973800bb3d0c91b5ab91cdf (patch) | |
| tree | 8abd91edd288284cf3cc47949e749f881cfaff8e /packages/backend/src/core/NotificationService.ts | |
| parent | Merge pull request #13045 from misskey-dev/develop (diff) | |
| parent | New translations ja-jp.yml (Chinese Traditional) (#13480) (diff) | |
| download | sharkey-7e706ea6693781fb8973800bb3d0c91b5ab91cdf.tar.gz sharkey-7e706ea6693781fb8973800bb3d0c91b5ab91cdf.tar.bz2 sharkey-7e706ea6693781fb8973800bb3d0c91b5ab91cdf.zip | |
Merge pull request #13447 from misskey-dev/develop
Release: 2024.3.0
Diffstat (limited to 'packages/backend/src/core/NotificationService.ts')
| -rw-r--r-- | packages/backend/src/core/NotificationService.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts index ee16193579..68ad92f396 100644 --- a/packages/backend/src/core/NotificationService.ts +++ b/packages/backend/src/core/NotificationService.ts @@ -126,6 +126,14 @@ export class NotificationService implements OnApplicationShutdown { this.cacheService.userFollowingsCache.fetch(notifieeId).then(followings => Object.hasOwn(followings, notifierId)), this.cacheService.userFollowingsCache.fetch(notifierId).then(followings => Object.hasOwn(followings, notifieeId)), ]); + if (!(isFollowing && isFollower)) { + return null; + } + } else if (recieveConfig?.type === 'followingOrFollower') { + const [isFollowing, isFollower] = await Promise.all([ + this.cacheService.userFollowingsCache.fetch(notifieeId).then(followings => Object.hasOwn(followings, notifierId)), + this.cacheService.userFollowingsCache.fetch(notifierId).then(followings => Object.hasOwn(followings, notifieeId)), + ]); if (!isFollowing && !isFollower) { return null; } @@ -155,6 +163,8 @@ export class NotificationService implements OnApplicationShutdown { const packed = await this.notificationEntityService.pack(notification, notifieeId, {}); + if (packed == null) return null; + // Publish notification event this.globalEventService.publishMainStream(notifieeId, 'notification', packed); @@ -205,6 +215,15 @@ export class NotificationService implements OnApplicationShutdown { } @bindThis + public async flushAllNotifications(userId: MiUser['id']) { + await Promise.all([ + this.redisClient.del(`notificationTimeline:${userId}`), + this.redisClient.del(`latestReadNotification:${userId}`), + ]); + this.globalEventService.publishMainStream(userId, 'notificationFlushed'); + } + + @bindThis public dispose(): void { this.#shutdownController.abort(); } |