Skip to content

Node.js based forum software built for the modern web

fix: notifications.markAllRead

Barış Soner Uşaklıbf243e077828
diff --git a/src/notifications.js b/src/notifications.js
index 7f7bb5268a..df7cf51fb4 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -383,8 +383,17 @@ Notifications.markReadMultiple = async function (nids, uid) {
};
Notifications.markAllRead = async function (uid) {
- const nids = await db.getSortedSetRevRange(`uid:${uid}:notifications:unread`, 0, 99);
- await Notifications.markReadMultiple(nids, uid);
+ await batch.processSortedSet(`uid:${uid}:notifications:unread`, async (unreadNotifs) => {
+ const nids = unreadNotifs.map(n => n && n.value);
+ const datetimes = unreadNotifs.map(n => n && n.score);
+ await Promise.all([
+ db.sortedSetRemove(`uid:${uid}:notifications:unread`, nids),
+ db.sortedSetAdd(`uid:${uid}:notifications:read`, datetimes, nids),
+ ]);
+ }, {
+ withScores: true,
+ batch: 500,
+ });
};
Notifications.prune = async function () {