Skip to content

Node.js based forum software built for the modern web

fix: filter out notifications that are from pids that are

Barış Soner Uşaklı3bfdf62218f5
diff --git a/src/user/notifications.js b/src/user/notifications.js
index 69d59fee8c..efcebed0d4 100644
--- a/src/user/notifications.js
+++ b/src/user/notifications.js
@@ -118,12 +118,19 @@ UserNotifications.getNotifications = async function (nids, uid) {
user.getSettings(uid),
]);
+ const postNotifications = notifObjs.filter(n => n && n.pid);
+ const pids = _.uniq(postNotifications.map(n => String(n.pid)));
+ const visiblePids = new Set(await privileges.posts.filter('topics:read', pids, uid));
+
const deletedNids = [];
let notificationData = notifObjs.filter((notification, index) => {
if (!notification || !notification.nid) {
deletedNids.push(nids[index]);
}
if (notification) {
+ if (notification.pid && !visiblePids.has(String(notification.pid))) {
+ return false;
+ }
notification.read = isRead[index];
notification.readClass = !notification.read ? 'unread' : '';
}