-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: omnichannel on-hold feature (#28252)
- Loading branch information
Showing
31 changed files
with
636 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
"@rocket.chat/core-services": patch | ||
"@rocket.chat/core-typings": patch | ||
"@rocket.chat/model-typings": patch | ||
"@rocket.chat/rest-typings": patch | ||
--- | ||
|
||
fix: Resume on-hold chat not working with max-chat's allowed per agent config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 45 additions & 24 deletions
69
apps/meteor/ee/app/livechat-enterprise/server/api/rooms.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 16 additions & 8 deletions
24
apps/meteor/ee/app/livechat-enterprise/server/hooks/afterOnHoldChatResumed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; | ||
|
||
import { callbacks } from '../../../../../lib/callbacks'; | ||
import { LivechatEnterprise } from '../lib/LivechatEnterprise'; | ||
import { AutoCloseOnHoldScheduler } from '../lib/AutoCloseOnHoldScheduler'; | ||
import { cbLogger } from '../lib/logger'; | ||
|
||
const handleAfterOnHoldChatResumed = async (room: any): Promise<void> => { | ||
if (!room?._id || !room.onHold) { | ||
cbLogger.debug('Skipping callback. No room provided or room is not on hold'); | ||
return; | ||
type IRoom = Pick<IOmnichannelRoom, '_id'>; | ||
|
||
const handleAfterOnHoldChatResumed = async (room: IRoom): Promise<IRoom> => { | ||
if (!room?._id) { | ||
cbLogger.debug('Skipping callback. No room provided'); | ||
return room; | ||
} | ||
|
||
cbLogger.debug(`Removing current on hold timers for room ${room._id}`); | ||
void LivechatEnterprise.releaseOnHoldChat(room); | ||
const { _id: roomId } = room; | ||
|
||
cbLogger.debug(`Removing current on hold timers for room ${roomId}`); | ||
await AutoCloseOnHoldScheduler.unscheduleRoom(roomId); | ||
|
||
return room; | ||
}; | ||
|
||
callbacks.add( | ||
'livechat:afterOnHoldChatResumed', | ||
(room) => handleAfterOnHoldChatResumed(room), | ||
handleAfterOnHoldChatResumed, | ||
callbacks.priority.HIGH, | ||
'livechat-after-on-hold-chat-resumed', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 34 additions & 12 deletions
46
apps/meteor/ee/app/livechat-enterprise/server/hooks/onCloseLivechat.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,46 @@ | ||
import type { IOmnichannelRoom } from '@rocket.chat/core-typings'; | ||
import { LivechatRooms, Subscriptions } from '@rocket.chat/models'; | ||
|
||
import { callbacks } from '../../../../../lib/callbacks'; | ||
import { settings } from '../../../../../app/settings/server'; | ||
import { debouncedDispatchWaitingQueueStatus } from '../lib/Helper'; | ||
import { LivechatEnterprise } from '../lib/LivechatEnterprise'; | ||
import { callbackLogger } from '../../../../../app/livechat/server/lib/callbackLogger'; | ||
import { AutoCloseOnHoldScheduler } from '../lib/AutoCloseOnHoldScheduler'; | ||
|
||
callbacks.add( | ||
'livechat.closeRoom', | ||
async (params) => { | ||
const { room } = params; | ||
type LivechatCloseCallbackParams = { | ||
room: IOmnichannelRoom; | ||
}; | ||
|
||
await LivechatEnterprise.releaseOnHoldChat(room); | ||
const onCloseLivechat = async (params: LivechatCloseCallbackParams) => { | ||
const { | ||
room, | ||
room: { _id: roomId }, | ||
} = params; | ||
|
||
if (!settings.get('Livechat_waiting_queue')) { | ||
return params; | ||
} | ||
callbackLogger.debug(`[onCloseLivechat] clearing onHold related data for room ${roomId}`); | ||
|
||
const { departmentId } = room || {}; | ||
debouncedDispatchWaitingQueueStatus(departmentId); | ||
await Promise.all([ | ||
LivechatRooms.unsetOnHoldByRoomId(roomId), | ||
Subscriptions.unsetOnHoldByRoomId(roomId), | ||
AutoCloseOnHoldScheduler.unscheduleRoom(roomId), | ||
]); | ||
|
||
callbackLogger.debug(`[onCloseLivechat] clearing onHold related data for room ${roomId} completed`); | ||
|
||
if (!settings.get('Livechat_waiting_queue')) { | ||
return params; | ||
}, | ||
} | ||
|
||
const { departmentId } = room || {}; | ||
callbackLogger.debug(`[onCloseLivechat] dispatching waiting queue status for department ${departmentId}`); | ||
debouncedDispatchWaitingQueueStatus(departmentId); | ||
|
||
return params; | ||
}; | ||
|
||
callbacks.add( | ||
'livechat.closeRoom', | ||
(params: LivechatCloseCallbackParams) => onCloseLivechat(params), | ||
callbacks.priority.HIGH, | ||
'livechat-waiting-queue-monitor-close-room', | ||
); |
Oops, something went wrong.