-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[EE] Improve Forwarding Department behaviour with Waiting queue feature #22043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2b50040
[EE] Fix Forwarding Department not working with Waiting queue feature
murtaza98 26a7704
Merge branch 'develop' into ee-livechat-waiting-queue-fix
murtaza98 d9fe3e3
add waiting queue feature enabled check
murtaza98 1b5c973
Refactor
murtaza98 b4b3c3d
Fix forwarding of agents not working
murtaza98 b765c3f
Merge branch 'develop' into ee-livechat-waiting-queue-fix
renatobecker 0c6f7ec
Apply suggestions from code review
murtaza98 d750c59
Handle transfer api response properly on client + refactor
murtaza98 53eec95
Avoid passing unnecessary params
murtaza98 e091231
Merge branch 'develop' into ee-livechat-waiting-queue-fix
renatobecker deccab9
Remove throw error.
renatobecker 85b015d
Improve throw message logic.
renatobecker c2e568d
Merge branch 'develop' into ee-livechat-waiting-queue-fix
renatobecker bf90764
Fix on-hold queue. Methods have been removed in another PR.
renatobecker d49c8fe
Remove all subscription from a chat placed on-hold.
renatobecker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
54 changes: 44 additions & 10 deletions
54
ee/app/livechat-enterprise/server/hooks/onAgentAssignmentFailed.ts
This file contains hidden or 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,59 @@ | ||
| import { callbacks } from '../../../../../app/callbacks/server'; | ||
| import { LivechatInquiry, Subscriptions, LivechatRooms } from '../../../../../app/models/server'; | ||
| import { queueInquiry } from '../../../../../app/livechat/server/lib/QueueManager'; | ||
| import { RoutingManager } from '../../../../../app/livechat/server/lib/RoutingManager'; | ||
| import { settings } from '../../../../../app/settings/server'; | ||
| import { Livechat } from '../../../../../app/livechat/server/lib/Livechat'; | ||
|
|
||
| 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 }; clienAction?: boolean} }): Promise<any> => { | ||
| if (!inquiry || !room) { | ||
| return; | ||
| } | ||
|
|
||
| const { _id: roomId, servedBy } = room; | ||
| if (room.onHold) { | ||
| const { _id: roomId, servedBy } = 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); | ||
| if (servedBy?._id) { | ||
| Subscriptions.removeByRoomIdAndUserId(roomId, servedBy._id); | ||
| } | ||
|
|
||
| const newInquiry = LivechatInquiry.findOneById(inquiryId); | ||
|
|
||
| await queueInquiry(room, newInquiry); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| const newInquiry = LivechatInquiry.findOneById(inquiryId); | ||
| if (!settings.get('Livechat_waiting_queue')) { | ||
| return; | ||
| } | ||
|
|
||
| const { forwardingToDepartment: { oldDepartmentId, transferData } = {}, forwardingToDepartment } = options; | ||
| if (!forwardingToDepartment) { | ||
| return; | ||
| } | ||
|
|
||
| const { department: newDepartmentId } = inquiry; | ||
|
|
||
| if (!newDepartmentId || !oldDepartmentId || newDepartmentId === oldDepartmentId) { | ||
| return; | ||
| } | ||
|
|
||
| // Undo the FAKE Department we did before RoutingManager.delegateInquiry() | ||
| inquiry.department = oldDepartmentId; | ||
| RoutingManager.unassignAgent(inquiry, newDepartmentId); | ||
|
|
||
| LivechatInquiry.readyInquiry(inquiry._id); | ||
|
|
||
| const newInquiry = LivechatInquiry.findOneById(inquiry._id); | ||
|
|
||
| await queueInquiry(room, newInquiry); | ||
|
|
||
| Livechat.saveTransferHistory(room, transferData); | ||
| }; | ||
|
|
||
| callbacks.add('livechat.onAgentAssignmentFailed', handleOnAgentAssignmentFailed, callbacks.priority.HIGH, 'livechat-agent-assignment-failed'); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.