mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: keep notifs for one month, load 50 notifications instead of 30
This commit is contained in:
@@ -318,8 +318,8 @@ Notifications.markAllRead = async function (uid) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Notifications.prune = async function () {
|
Notifications.prune = async function () {
|
||||||
const week = 604800000;
|
const month = 2592000000;
|
||||||
const cutoffTime = Date.now() - week;
|
const cutoffTime = Date.now() - month;
|
||||||
const nids = await db.getSortedSetRangeByScore('notifications', 0, 500, '-inf', cutoffTime);
|
const nids = await db.getSortedSetRangeByScore('notifications', 0, 500, '-inf', cutoffTime);
|
||||||
if (!nids.length) {
|
if (!nids.length) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ UserNotifications.get = async function (uid) {
|
|||||||
return { read: [], unread: [] };
|
return { read: [], unread: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
let unread = await getNotificationsFromSet(`uid:${uid}:notifications:unread`, uid, 0, 29);
|
let unread = await getNotificationsFromSet(`uid:${uid}:notifications:unread`, uid, 0, 49);
|
||||||
unread = unread.filter(Boolean);
|
unread = unread.filter(Boolean);
|
||||||
let read = [];
|
let read = [];
|
||||||
if (unread.length < 30) {
|
if (unread.length < 50) {
|
||||||
read = await getNotificationsFromSet(`uid:${uid}:notifications:read`, uid, 0, 29 - unread.length);
|
read = await getNotificationsFromSet(`uid:${uid}:notifications:read`, uid, 0, 49 - unread.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await plugins.hooks.fire('filter:user.notifications.get', {
|
return await plugins.hooks.fire('filter:user.notifications.get', {
|
||||||
|
|||||||
Reference in New Issue
Block a user