Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts
Original file line number Diff line number Diff line change
@@ -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');
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
1 change: 1 addition & 0 deletions ee/app/livechat-enterprise/server/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ import './onAgentAssignmentFailed';
import './afterOnHoldChatResumed';
import './afterReturnRoomAsInquiry';
import './applyDepartmentRestrictions';
import './afterForwardChatToAgent';