-
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.
[Patch] [EE] Improve Forwarding Department behaviour with Waiting que…
…ue feature (#22077) * [EE] Fix Forwarding Department not working with Waiting queue feature (cherry picked from commit 2b50040) * add waiting queue feature enabled check (cherry picked from commit d9fe3e3) * Refactor (cherry picked from commit 1b5c973) * Fix forwarding of agents not working (cherry picked from commit b4b3c3d) * Apply suggestions from code review Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> (cherry picked from commit 0c6f7ec) * Handle transfer api response properly on client + refactor (cherry picked from commit d750c59) * Avoid passing unnecessary params (cherry picked from commit 53eec95) * Remove throw error. (cherry picked from commit deccab9) * Improve throw message logic. (cherry picked from commit 85b015d) * Fix conflicts * Remove all subscription from a chat placed on-hold. (cherry picked from commit d49c8fe) * up fuselage version * add string-helpers package * [EE] Improve Forwarding Department behaviour with Waiting queue feature (#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> Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com> Co-authored-by: Tiago Evangelista Pinto <tiago.evangelista@rocket.chat>
- Loading branch information
1 parent
a1d4be4
commit 29dac28
Showing
14 changed files
with
141 additions
and
85 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
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
Oops, something went wrong.