Skip to content

Commit 8d4507d

Browse files
authored
fix: missing "user left" system message after omnichannel room forward (#41480)
1 parent 1d60700 commit 8d4507d

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rocket.chat/meteor': patch
3+
---
4+
5+
Fixes an issue where the "user left" system message could be added to an Omnichannel conversation only after the forwarding process had already finished, causing it to appear out of order in the conversation history

apps/meteor/server/lib/omnichannel/RoutingManager.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,11 @@ export const RoutingManager: Routing = {
371371
async removeAllRoomSubscriptions(room, ignoreUser) {
372372
const { _id: roomId } = room;
373373

374-
const subscriptions = await Subscriptions.findByRoomId(roomId).toArray();
375-
subscriptions?.forEach(({ u }) => {
376-
if (ignoreUser && ignoreUser._id === u._id) {
377-
return;
374+
for await (const { u } of Subscriptions.findByRoomId(roomId, { projection: { u: 1 } })) {
375+
if (ignoreUser?._id === u._id) {
376+
continue;
378377
}
379-
void removeAgentFromSubscription(roomId, u);
380-
});
378+
await removeAgentFromSubscription(roomId, u);
379+
}
381380
},
382381
};

0 commit comments

Comments
 (0)