-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EE] Improve Forwarding Department behaviour with Waiting queue featu…
…re (#22043) * [EE] Fix Forwarding Department not working with Waiting queue feature * add waiting queue feature enabled check * Refactor * Fix forwarding of agents not working * Apply suggestions from code review Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> * Handle transfer api response properly on client + refactor * Avoid passing unnecessary params * Remove throw error. * Improve throw message logic. * Fix on-hold queue. Methods have been removed in another PR. * Remove all subscription from a chat placed on-hold. Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
- Loading branch information
1 parent
d86deca
commit 63248e1
Showing
11 changed files
with
74 additions
and
31 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
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
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
42 changes: 31 additions & 11 deletions
42
ee/app/livechat-enterprise/server/hooks/onAgentAssignmentFailed.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,25 +1,45 @@ | ||
import { callbacks } from '../../../../../app/callbacks/server'; | ||
import { LivechatInquiry, Subscriptions, LivechatRooms } from '../../../../../app/models/server'; | ||
import { queueInquiry } from '../../../../../app/livechat/server/lib/QueueManager'; | ||
import { settings } from '../../../../../app/settings/server'; | ||
|
||
const handleOnAgentAssignmentFailed = async ({ inquiry, room }: { inquiry: any; room: any }): Promise<any> => { | ||
if (!inquiry || !room || !room.onHold) { | ||
const handleOnAgentAssignmentFailed = async ({ inquiry, room, options }: { inquiry: any; room: any; options: { forwardingToDepartment?: { oldDepartmentId: string; transferData: any }; clientAction?: boolean} }): Promise<any> => { | ||
if (!inquiry || !room) { | ||
return; | ||
} | ||
|
||
const { _id: roomId, servedBy } = room; | ||
if (room.onHold) { | ||
const { _id: roomId } = room; | ||
|
||
const { _id: inquiryId } = inquiry; | ||
LivechatInquiry.readyInquiry(inquiryId); | ||
LivechatInquiry.removeDefaultAgentById(inquiryId); | ||
LivechatRooms.removeAgentByRoomId(roomId); | ||
if (servedBy?._id) { | ||
Subscriptions.removeByRoomIdAndUserId(roomId, servedBy._id); | ||
const { _id: inquiryId } = inquiry; | ||
LivechatInquiry.readyInquiry(inquiryId); | ||
LivechatInquiry.removeDefaultAgentById(inquiryId); | ||
LivechatRooms.removeAgentByRoomId(roomId); | ||
Subscriptions.removeByRoomId(roomId); | ||
const newInquiry = LivechatInquiry.findOneById(inquiryId); | ||
|
||
await queueInquiry(room, newInquiry); | ||
|
||
return; | ||
} | ||
|
||
if (!settings.get('Livechat_waiting_queue')) { | ||
return; | ||
} | ||
|
||
const newInquiry = LivechatInquiry.findOneById(inquiryId); | ||
const { forwardingToDepartment: { oldDepartmentId } = {}, forwardingToDepartment } = options; | ||
if (!forwardingToDepartment) { | ||
return; | ||
} | ||
|
||
const { department: newDepartmentId } = inquiry; | ||
|
||
if (!newDepartmentId || !oldDepartmentId || newDepartmentId === oldDepartmentId) { | ||
return; | ||
} | ||
|
||
await queueInquiry(room, newInquiry); | ||
room.chatQueued = true; | ||
return room; | ||
}; | ||
|
||
callbacks.add('livechat.onAgentAssignmentFailed', handleOnAgentAssignmentFailed, callbacks.priority.HIGH, 'livechat-agent-assignment-failed'); |
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