diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/index.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/index.ts index a4b66087be2e8..8d59c834e2b5b 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/index.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/index.ts @@ -27,3 +27,4 @@ import './sendPdfTranscriptOnClose'; import './applyRoomRestrictions'; import './afterTagRemoved'; import './manageDepartmentUnit'; +import './autoCloseQueued'; diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts index bc2d4fb6a3fb4..fd6fd9b8109ce 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts @@ -1,7 +1,6 @@ import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; -import { LivechatRooms, Subscriptions } from '@rocket.chat/models'; +import { LivechatRooms } from '@rocket.chat/models'; -import { notifyOnSubscriptionChangedByRoomId } from '../../../../../app/lib/server/lib/notifyListener'; import { settings } from '../../../../../app/settings/server'; import { callbacks } from '../../../../../lib/callbacks'; import { AutoCloseOnHoldScheduler } from '../lib/AutoCloseOnHoldScheduler'; @@ -17,14 +16,9 @@ const onCloseLivechat = async (params: LivechatCloseCallbackParams) => { room: { _id: roomId }, } = params; - const responses = await Promise.all([ - LivechatRooms.unsetOnHoldByRoomId(roomId), - Subscriptions.unsetOnHoldByRoomId(roomId), - AutoCloseOnHoldScheduler.unscheduleRoom(roomId), - ]); - - if (responses[1].modifiedCount) { - void notifyOnSubscriptionChangedByRoomId(roomId); + await LivechatRooms.unsetOnHoldByRoomId(roomId); + if (settings.get('Livechat_auto_close_on_hold_chats_timeout')) { + await AutoCloseOnHoldScheduler.unscheduleRoom(roomId); } if (!settings.get('Livechat_waiting_queue')) { @@ -41,5 +35,5 @@ callbacks.add( 'livechat.closeRoom', (params: LivechatCloseCallbackParams) => onCloseLivechat(params), callbacks.priority.HIGH, - 'livechat-waiting-queue-monitor-close-room', + 'livechat-on-close-livechat-remove-on-hold-and-dispatch-waiting-queue', ); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadConfigApi.ts b/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadConfigApi.ts index c0e966cb24fca..01b4600ca954a 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadConfigApi.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/hooks/onLoadConfigApi.ts @@ -6,9 +6,7 @@ callbacks.add( async (options) => { const { room } = options; - const queueInfo = await getLivechatQueueInfo(room); - const customFields = await getLivechatCustomFields(); - + const [queueInfo, customFields] = await Promise.all([getLivechatQueueInfo(room), getLivechatCustomFields()]); return { ...(queueInfo && { queueInfo }), ...(customFields && { customFields }),