This commit is contained in:
tamaina 2021-09-05 16:16:06 +09:00
parent bac1de6620
commit e2d7e50621
1 changed files with 3 additions and 6 deletions

View File

@ -25,16 +25,13 @@ export async function readNotificationByQuery(
userId: User['id'], userId: User['id'],
query: Record<string, any> query: Record<string, any>
) { ) {
// Update documents const notificationIds = await Notifications.find({
await Notifications.update({
...query, ...query,
notifieeId: userId, notifieeId: userId,
isRead: false isRead: false
}, { }).then(notifications => notifications.map(notification => notification.id));
isRead: true
});
if (!await Users.getHasUnreadNotification(userId)) return postReadAllNotifications(userId); return readNotification(userId, notificationIds)
} }
function postReadAllNotifications(userId: User['id']) { function postReadAllNotifications(userId: User['id']) {