The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/ee/app/livechat-enterprise/server/methods/resumeOnHold.ts

30 lines
1.2 KiB

import { Meteor } from 'meteor/meteor';
import { LivechatRooms, LivechatInquiry } from '../../../../../app/models/server';
import { RoutingManager } from '../../../../../app/livechat/server/lib/RoutingManager';
import { callbacks } from '../../../../../app/callbacks/server';
Meteor.methods({
async 'livechat:resumeOnHold'(roomId, options = { clientAction: false }) {
const room = await LivechatRooms.findOneById(roomId);
if (!room || room.t !== 'l') {
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'livechat:resumeOnHold' });
}
if (!room.onHold) {
throw new Meteor.Error('room-closed', 'Room is not OnHold', { method: 'livechat:resumeOnHold' });
}
const { servedBy: { _id: agentId, username } } = room;
const inquiry = LivechatInquiry.findOneByRoomId(roomId, {});
if (!inquiry) {
throw new Meteor.Error('inquiry-not-found', 'Error! No inquiry found for this room', { method: 'livechat:resumeOnHold' });
}
await RoutingManager.takeInquiry(inquiry, { agentId, username }, options);
const updatedRoom = LivechatRooms.findOneById(roomId);
updatedRoom && Meteor.defer(() => callbacks.run('livechat:afterOnHoldChatResumed', updatedRoom));
},
});