mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: handle public chat rooms too
This commit is contained in:
@@ -70,13 +70,13 @@ module.exports = function (Messaging) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendNotification(fromUid, roomId, messageObj);
|
await sendNotification(fromUid, roomId, isPublic, messageObj);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
winston.error(`[messaging/notifications] Unabled to send notification\n${err.stack}`);
|
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);
|
fromUid = parseInt(fromUid, 10);
|
||||||
|
|
||||||
const [settings, roomData] = await Promise.all([
|
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
|
// 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)));
|
uidsToNotify = uidsToNotify.filter(uid => !realtimeUids.includes(parseInt(uid, 10)));
|
||||||
|
|
||||||
if (uidsToNotify.length) {
|
if (uidsToNotify.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user