From 6a696c43a3e33b91f04115ba08045bb18086f0aa Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 25 Oct 2023 12:11:37 -0400 Subject: [PATCH] fix: handle public chat rooms too --- src/messaging/notifications.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/messaging/notifications.js b/src/messaging/notifications.js index 81a784944f..f20af5468c 100644 --- a/src/messaging/notifications.js +++ b/src/messaging/notifications.js @@ -70,13 +70,13 @@ module.exports = function (Messaging) { } try { - await sendNotification(fromUid, roomId, messageObj); + await sendNotification(fromUid, roomId, isPublic, messageObj); } catch (err) { winston.error(`[messaging/notifications] Unabled to send notification\n${err.stack}`); } }; - async function sendNotification(fromUid, roomId, messageObj) { + async function sendNotification(fromUid, roomId, isPublic, messageObj) { fromUid = parseInt(fromUid, 10); const [settings, roomData] = await Promise.all([ @@ -100,7 +100,7 @@ module.exports = function (Messaging) { }); // Suppress notifications for users who are literally present in the room - const realtimeUids = await io.getUidsInRoom(`chat_room_${roomId}`); + const realtimeUids = await io.getUidsInRoom(`chat_room_${isPublic ? 'public_' : ''}${roomId}`); uidsToNotify = uidsToNotify.filter(uid => !realtimeUids.includes(parseInt(uid, 10))); if (uidsToNotify.length) {