From 627ac800af6e5c6939abfda90a911fca897e269b Mon Sep 17 00:00:00 2001 From: Adarsh SRN Date: Tue, 3 Feb 2026 07:18:40 +0000 Subject: [PATCH 1/2] Refactor: Improved user notification filtering logic in Messaging module (by reducing binary expression complexity) --- src/messaging/notifications.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/messaging/notifications.js b/src/messaging/notifications.js index 1c9475608d..f7b0ed73b3 100644 --- a/src/messaging/notifications.js +++ b/src/messaging/notifications.js @@ -99,12 +99,17 @@ module.exports = function (Messaging) { const roomDefault = roomData.notificationSetting; const uidsToNotify = []; const { ALLMESSAGES } = Messaging.notificationSettings; + console.log('Andrew ID: ASRN'); await batch.processSortedSet(`chat:room:${roomId}:uids:online`, async (uids) => { uids = uids.filter( - uid => utils.isNumber(uid) && - (parseInt((settings && settings[uid]) || roomDefault, 10) === ALLMESSAGES) && - String(fromUid) !== String(uid) && - !realtimeUids.includes(parseInt(uid, 10)) + (uid) => { + const isNumeric = utils.isNumber(uid); + const isNotSelf = String(fromUid) !== String(uid); + const combinedSettings = (settings && settings[uid]); + const showAll = parseInt(combinedSettings || roomDefault, 10) === ALLMESSAGES; + const isPresent = realtimeUids.includes(parseInt(uid, 10)); + return Boolean(isNumeric && isNotSelf && showAll && !isPresent); + } ); const hasRead = await Messaging.hasRead(uids, roomId); uidsToNotify.push(...uids.filter((uid, index) => !hasRead[index])); From 84f7d76598cf71e2812c60e9eda0f7ef5c7aa295 Mon Sep 17 00:00:00 2001 From: Adarsh SRN Date: Tue, 3 Feb 2026 07:20:34 +0000 Subject: [PATCH 2/2] Fix Issue #188: Remove debug console log for final commit --- src/messaging/notifications.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/messaging/notifications.js b/src/messaging/notifications.js index f7b0ed73b3..33e6846301 100644 --- a/src/messaging/notifications.js +++ b/src/messaging/notifications.js @@ -99,7 +99,6 @@ module.exports = function (Messaging) { const roomDefault = roomData.notificationSetting; const uidsToNotify = []; const { ALLMESSAGES } = Messaging.notificationSettings; - console.log('Andrew ID: ASRN'); await batch.processSortedSet(`chat:room:${roomId}:uids:online`, async (uids) => { uids = uids.filter( (uid) => {