refactor: Remove `livechat.roomQueued` callback (#35990)

pull/35962/head
Kevin Aleman 8 months ago committed by GitHub
parent 6862706c20
commit af425334b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 13
      apps/meteor/app/livechat/server/hooks/sendToCRM.ts
  2. 4
      apps/meteor/app/livechat/server/lib/Helper.ts
  3. 5
      apps/meteor/app/livechat/server/lib/QueueManager.ts
  4. 8
      apps/meteor/app/livechat/server/lib/hooks.ts
  5. 2
      apps/meteor/lib/callbacks.ts

@ -166,19 +166,6 @@ callbacks.add(
'livechat-send-crm-close-room',
);
callbacks.add(
'livechat.chatQueued',
(room) => {
if (!settings.get('Livechat_webhook_on_chat_queued')) {
return room;
}
return sendToCRM('LivechatSessionQueued', room);
},
callbacks.priority.MEDIUM,
'livechat-send-crm-room-queued',
);
callbacks.add(
'livechat.afterForwardChatToAgent',
async (params) => {

@ -41,7 +41,7 @@ import { queueInquiry, saveQueueInquiry } from './QueueManager';
import { RoutingManager } from './RoutingManager';
import { isVerifiedChannelInSource } from './contacts/isVerifiedChannelInSource';
import { migrateVisitorIfMissingContact } from './contacts/migrateVisitorIfMissingContact';
import { beforeNewRoom } from './hooks';
import { afterRoomQueued, beforeNewRoom } from './hooks';
import { checkOnlineAgents, getOnlineAgents } from './service-status';
import { saveTransferHistory } from './transfer';
import { callbacks } from '../../../../lib/callbacks';
@ -413,7 +413,7 @@ export const dispatchInquiryQueued = async (inquiry: ILivechatInquiryRecord, age
return;
}
setImmediate(() => callbacks.run('livechat.chatQueued', room));
void afterRoomQueued(room);
if (RoutingManager.getConfig()?.autoAssignAgent) {
return;

@ -23,7 +23,7 @@ import { createLivechatRoom, createLivechatInquiry, allowAgentSkipQueue, prepare
import { RoutingManager } from './RoutingManager';
import { isVerifiedChannelInSource } from './contacts/isVerifiedChannelInSource';
import { checkOnlineForDepartment } from './departmentsLib';
import { afterInquiryQueued, beforeDelegateAgent, onNewRoom } from './hooks';
import { afterInquiryQueued, afterRoomQueued, beforeDelegateAgent, onNewRoom } from './hooks';
import { checkOnlineAgents, getOnlineAgents } from './service-status';
import { getInquirySortMechanismSetting } from './settings';
import { dispatchInquiryPosition } from '../../../../ee/app/livechat-enterprise/server/lib/Helper';
@ -172,8 +172,7 @@ export class QueueManager {
}
if (inquiry.status === LivechatInquiryStatus.QUEUED) {
await afterInquiryQueued(inquiry);
await callbacks.run('livechat.chatQueued', room);
await Promise.all([afterInquiryQueued(inquiry), afterRoomQueued(room)]);
if (defaultAgent) {
logger.debug(`Setting default agent for inquiry ${inquiry._id} to ${defaultAgent.username}`);

@ -124,3 +124,11 @@ export const afterTakeInquiry = makeFunction(
export const afterInquiryQueued = makeFunction(async (_inquiry: ILivechatInquiryRecord) => {
return void 0;
});
export const afterRoomQueued = makeFunction((room: IOmnichannelRoom) => {
if (!settings.get('Livechat_webhook_on_chat_queued')) {
return;
}
return sendToCRM('LivechatSessionQueued', room);
});

@ -181,7 +181,6 @@ type ChainedCallbackSignatures = {
};
'livechat.beforeListTags': () => ILivechatTag[];
'livechat.offlineMessage': (data: { name: string; email: string; message: string; department?: string; host?: string }) => void;
'livechat.chatQueued': (room: IOmnichannelRoom) => IOmnichannelRoom;
'livechat.leadCapture': (room: IOmnichannelRoom) => IOmnichannelRoom;
'beforeSendMessageNotifications': (message: string) => string;
'livechat.onAgentAssignmentFailed': (
@ -220,7 +219,6 @@ export type Hook =
| 'beforeRemoveFromRoom'
| 'beforeValidateLogin'
| 'livechat.beforeForwardRoomToDepartment'
| 'livechat.chatQueued'
| 'livechat.checkAgentBeforeTakeInquiry'
| 'livechat.sendTranscript'
| 'livechat.closeRoom'

Loading…
Cancel
Save