diff --git a/.changeset/eleven-buses-return.md b/.changeset/eleven-buses-return.md new file mode 100644 index 0000000000000..6ecf152827ced --- /dev/null +++ b/.changeset/eleven-buses-return.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes an issue where rooms transferred to a department's queue could get stuck—marked as taken but with no agent assigned. \ No newline at end of file diff --git a/apps/meteor/app/livechat/server/lib/RoutingManager.ts b/apps/meteor/app/livechat/server/lib/RoutingManager.ts index 6d422819a88aa..be18f07b08f95 100644 --- a/apps/meteor/app/livechat/server/lib/RoutingManager.ts +++ b/apps/meteor/app/livechat/server/lib/RoutingManager.ts @@ -180,6 +180,12 @@ export const RoutingManager: Routing = { const { servedBy } = room; + if (servedBy) { + await LivechatRooms.removeAgentByRoomId(rid); + await this.removeAllRoomSubscriptions(room); + await dispatchAgentDelegated(rid); + } + if (shouldQueue) { const queuedInquiry = await LivechatInquiry.queueInquiry(inquiry._id, room.lastMessage); if (queuedInquiry) { @@ -192,12 +198,6 @@ export const RoutingManager: Routing = { } } - if (servedBy) { - await LivechatRooms.removeAgentByRoomId(rid); - await this.removeAllRoomSubscriptions(room); - await dispatchAgentDelegated(rid); - } - await dispatchInquiryQueued(inquiry); return true;