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'],
query: Record<string, any>
) {
// 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']) {