diff --git a/ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts b/ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts new file mode 100644 index 0000000000000..ee51c22dacab6 --- /dev/null +++ b/ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts @@ -0,0 +1,15 @@ +import { callbacks } from '../../../../../app/callbacks/server'; +import LivechatRooms from '../../../../../app/models/server/models/LivechatRooms'; + +callbacks.add('livechat.afterForwardChatToAgent', (options: { rid?: string } = {}) => { + const { rid } = options; + + const room = LivechatRooms.findOneById(rid); + if (!room) { + return options; + } + + (LivechatRooms as any).unsetPredictedVisitorAbandonmentByRoomId(rid); + + return options; +}, callbacks.priority.MEDIUM, 'livechat-after-forward-room-to-department'); diff --git a/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.js b/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.js index ed8b311c8835d..ee669c4d32a88 100644 --- a/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.js +++ b/ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.js @@ -1,26 +1,25 @@ import { callbacks } from '../../../../../app/callbacks/server'; import LivechatRooms from '../../../../../app/models/server/models/LivechatRooms'; import LivechatDepartment from '../../../../../app/models/server/models/LivechatDepartment'; -import { setPredictedVisitorAbandonmentTime } from '../lib/Helper'; callbacks.add('livechat.afterForwardChatToDepartment', (options) => { const { rid, newDepartmentId } = options; const room = LivechatRooms.findOneById(rid); if (!room) { - return; + return options; } - setPredictedVisitorAbandonmentTime(room); + LivechatRooms.unsetPredictedVisitorAbandonmentByRoomId(room._id); const department = LivechatDepartment.findOneById(newDepartmentId, { fields: { ancestors: 1 } }); if (!department) { - return; + return options; } const { departmentAncestors } = room; const { ancestors } = department; if (!ancestors && !departmentAncestors) { - return room; + return options; } LivechatRooms.updateDepartmentAncestorsById(room._id, ancestors); diff --git a/ee/app/livechat-enterprise/server/hooks/index.js b/ee/app/livechat-enterprise/server/hooks/index.js index 303d3b2e12d93..d236d62cb9940 100644 --- a/ee/app/livechat-enterprise/server/hooks/index.js +++ b/ee/app/livechat-enterprise/server/hooks/index.js @@ -19,3 +19,4 @@ import './onAgentAssignmentFailed'; import './afterOnHoldChatResumed'; import './afterReturnRoomAsInquiry'; import './applyDepartmentRestrictions'; +import './afterForwardChatToAgent';