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']) {