From 387fd8ff1b12aacec81431f7c971dc83b9b73146 Mon Sep 17 00:00:00 2001 From: cabaceira Date: Mon, 23 Oct 2023 20:56:08 +0100 Subject: [PATCH] fix validation order --- .../server/services/omnichannel.internalService.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/meteor/ee/app/livechat-enterprise/server/services/omnichannel.internalService.ts b/apps/meteor/ee/app/livechat-enterprise/server/services/omnichannel.internalService.ts index 6e71528cd252d..96428ae85d5b2 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/services/omnichannel.internalService.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/services/omnichannel.internalService.ts @@ -35,9 +35,6 @@ export class OmnichannelEE extends ServiceClassInternal implements IOmnichannelE const canRoomBePlacedOnHold = !room.onHold; const canAgentPlaceOnHold = !room.lastMessage.token; const canPlaceChatOnHold = canRoomBePlacedOnHold && (!restrictedOnHold || canAgentPlaceOnHold); - if (!canPlaceChatOnHold) { - throw new Error('error-contact-sent-last-message-so-cannot-place-on-hold'); - } if (!room || !isOmnichannelRoom(room)) { throw new Error('error-invalid-room'); @@ -49,6 +46,10 @@ export class OmnichannelEE extends ServiceClassInternal implements IOmnichannelE throw new Error('error-room-is-already-on-hold'); } + if (!canPlaceChatOnHold) { + throw new Error('error-contact-sent-last-message-so-cannot-place-on-hold'); + } + if (!room.servedBy) { throw new Error('error-unserved-rooms-cannot-be-placed-onhold'); }