diff --git a/app/livechat/server/lib/Helper.js b/app/livechat/server/lib/Helper.js index 5edaee2494563..fb42f39497243 100644 --- a/app/livechat/server/lib/Helper.js +++ b/app/livechat/server/lib/Helper.js @@ -437,7 +437,9 @@ export const forwardRoomToDepartment = async (room, guest, transferData) => { Livechat.saveTransferHistory(room, transferData); if (oldServedBy) { - RoutingManager.removeAllRoomSubscriptions(room, servedBy); + // if chat is queued then we don't ignore the new servedBy agent bcs at this + // point the chat is not assigned to him/her and it is still in the queue + RoutingManager.removeAllRoomSubscriptions(room, !chatQueued && servedBy); } if (!chatQueued && servedBy) { Messages.createUserJoinWithRoomIdAndUser(rid, servedBy); @@ -448,6 +450,8 @@ export const forwardRoomToDepartment = async (room, guest, transferData) => { if (chatQueued) { logger.debug(`Forwarding succesful. Marking inquiry ${ inquiry._id } as ready`); LivechatInquiry.readyInquiry(inquiry._id); + LivechatRooms.removeAgentByRoomId(rid); + dispatchAgentDelegated(rid, null); const newInquiry = LivechatInquiry.findOneById(inquiry._id); await queueInquiry(room, newInquiry);