Node.js based forum software built for the modern web
fix: suppress chat message notifications for users who are known to be in the chat room (uid is present in the corresponding socket.io room)
Julian Lam18c27d1ad35f
diff --git a/src/messaging/notifications.js b/src/messaging/notifications.jsindex 2dc78a03d4..81a784944f 100644--- a/src/messaging/notifications.js+++ b/src/messaging/notifications.js@@ -84,7 +84,7 @@ module.exports = function (Messaging) {Messaging.getRoomData(roomId),]);const roomDefault = roomData.notificationSetting;- const uidsToNotify = [];+ let uidsToNotify = [];const { ALLMESSAGES } = Messaging.notificationSettings;await batch.processSortedSet(`chat:room:${roomId}:uids:online`, async (uids) => {uids = uids.filter(@@ -99,6 +99,10 @@ module.exports = function (Messaging) {interval: 100,});+ // Suppress notifications for users who are literally present in the room+ const realtimeUids = await io.getUidsInRoom(`chat_room_${roomId}`);+ uidsToNotify = uidsToNotify.filter(uid => !realtimeUids.includes(parseInt(uid, 10)));+if (uidsToNotify.length) {const { displayname } = messageObj.fromUser;const isGroupChat = await Messaging.isGroupChat(roomId);