Skip to content

Commit

Permalink
fix validation order
Browse files Browse the repository at this point in the history
  • Loading branch information
cabaceira committed Oct 23, 2023
1 parent ff3ff68 commit 387fd8f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
}
Expand Down

0 comments on commit 387fd8f

Please sign in to comment.