[FIX][ENTERPRISE] Prevent Visitor Abandonment after forwarding chat (#22243)

* [FIX][EE] Prevent Visitor Abandonment after forwarding chat

* Fix Return value issue

* Fix callback return value.

Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
pull/22258/head
Murtaza Patrawala 4 years ago committed by GitHub
parent 7550e25c47
commit 1b568ca0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      ee/app/livechat-enterprise/server/hooks/afterForwardChatToAgent.ts
  2. 9
      ee/app/livechat-enterprise/server/hooks/afterForwardChatToDepartment.js
  3. 1
      ee/app/livechat-enterprise/server/hooks/index.js

@ -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');

@ -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);

@ -19,3 +19,4 @@ import './onAgentAssignmentFailed';
import './afterOnHoldChatResumed';
import './afterReturnRoomAsInquiry';
import './applyDepartmentRestrictions';
import './afterForwardChatToAgent';

Loading…
Cancel
Save