Skip to content

Node.js based forum software built for the modern web

fix(messaging): skip existing members in addUidsToRoom to preserve join timestamps

Julian Lamf34e2e8c22e5
diff --git a/src/messaging/rooms.js b/src/messaging/rooms.js
index 0060b9ee8c..e90efff43f 100644
--- a/src/messaging/rooms.js
+++ b/src/messaging/rooms.js
@@ -293,6 +293,11 @@ module.exports = function (Messaging) {
async function addUidsToRoom(uids, roomId) {
const now = Date.now();
+ const isMembers = await db.isSortedSetMembers(`chat:room:${roomId}:uids`, uids);
+ uids = uids.filter((uid, index) => !isMembers[index]);
+ if (!uids.length) {
+ return;
+ }
const timestamps = uids.map(() => now);
await Promise.all([