From e2d7e5062196a2f5e0434640ef171cb7f82da3d7 Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 5 Sep 2021 16:16:06 +0900 Subject: [PATCH] wip --- src/server/api/common/read-notification.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/server/api/common/read-notification.ts b/src/server/api/common/read-notification.ts index 176bbd4e46..77c775e837 100644 --- a/src/server/api/common/read-notification.ts +++ b/src/server/api/common/read-notification.ts @@ -25,16 +25,13 @@ export async function readNotificationByQuery( userId: User['id'], query: Record ) { - // Update documents - await Notifications.update({ + const notificationIds = await Notifications.find({ ...query, notifieeId: userId, isRead: false - }, { - isRead: true - }); + }).then(notifications => notifications.map(notification => notification.id)); - if (!await Users.getHasUnreadNotification(userId)) return postReadAllNotifications(userId); + return readNotification(userId, notificationIds) } function postReadAllNotifications(userId: User['id']) {