diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-03-02 16:36:49 +0000 |
|---|---|---|
| committer | Amelia Yukii <amelia.yukii@shourai.de> | 2024-03-02 16:36:49 +0000 |
| commit | af548d05ca821725eabd5a96241d3228b92186f0 (patch) | |
| tree | 6d23f6739482466abcc71965cd83f9bbfb2c3ae0 /packages/backend/src/core/NotificationService.ts | |
| parent | merge: Fix Images in ReadMe (!445) (diff) | |
| download | sharkey-af548d05ca821725eabd5a96241d3228b92186f0.tar.gz sharkey-af548d05ca821725eabd5a96241d3228b92186f0.tar.bz2 sharkey-af548d05ca821725eabd5a96241d3228b92186f0.zip | |
merge upstream for 2024.2.1
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(); } |