summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NotificationService.ts
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2023-04-06 06:11:59 +0900
committerGitHub <noreply@github.com>2023-04-06 06:11:59 +0900
commit2650a7a5b8ce95b343f932d029ddb2c20b38b073 (patch)
treeae4bc8a949184ada3e794115fea991fa9314781d /packages/backend/src/core/NotificationService.ts
parentci: fix syntax (diff)
downloadsharkey-2650a7a5b8ce95b343f932d029ddb2c20b38b073.tar.gz
sharkey-2650a7a5b8ce95b343f932d029ddb2c20b38b073.tar.bz2
sharkey-2650a7a5b8ce95b343f932d029ddb2c20b38b073.zip
fix: 通知インジケータが光りっぱなしになる問題を修正 (#10483)
* fix(misskey-js): ストリームがstringで送信される場合があるのを修正 * pnpm run api * force read notification * fix competition
Diffstat (limited to 'packages/backend/src/core/NotificationService.ts')
-rw-r--r--packages/backend/src/core/NotificationService.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts
index 366dc08c02..c44dddea41 100644
--- a/packages/backend/src/core/NotificationService.ts
+++ b/packages/backend/src/core/NotificationService.ts
@@ -43,6 +43,7 @@ export class NotificationService implements OnApplicationShutdown {
@bindThis
public async readAllNotification(
userId: User['id'],
+ force = false,
) {
const latestReadNotificationId = await this.redisClient.get(`latestReadNotification:${userId}`);
@@ -57,7 +58,7 @@ export class NotificationService implements OnApplicationShutdown {
this.redisClient.set(`latestReadNotification:${userId}`, latestNotificationId);
- if (latestReadNotificationId == null || (latestReadNotificationId < latestNotificationId)) {
+ if (force || latestReadNotificationId == null || (latestReadNotificationId < latestNotificationId)) {
return this.postReadAllNotifications(userId);
}
}
@@ -95,7 +96,7 @@ export class NotificationService implements OnApplicationShutdown {
...data,
} as Notification;
- this.redisClient.xadd(
+ const redisIdPromise = this.redisClient.xadd(
`notificationTimeline:${notifieeId}`,
'MAXLEN', '~', '300',
`${this.idService.parse(notification.id).date.getTime()}-*`,
@@ -109,7 +110,7 @@ export class NotificationService implements OnApplicationShutdown {
// 2秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する
setTimeout(2000, 'unread notification', { signal: this.#shutdownController.signal }).then(async () => {
const latestReadNotificationId = await this.redisClient.get(`latestReadNotification:${notifieeId}`);
- if (latestReadNotificationId && (latestReadNotificationId >= notification.id)) return;
+ if (latestReadNotificationId && (latestReadNotificationId >= await redisIdPromise)) return;
this.globalEventService.publishMainStream(notifieeId, 'unreadNotification', packed);
this.pushNotificationService.pushNotification(notifieeId, 'notification', packed);