regression: fix dispatchInquiryPosition not being fired on room creation (#32972)

e2e-flaky-tests^2
Guilherme Gazzo 1 year ago committed by GitHub
parent 46a502cc24
commit a38c342777
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      apps/meteor/app/livechat/server/lib/QueueManager.ts
  2. 6
      apps/meteor/ee/app/livechat-enterprise/server/lib/Helper.ts

@ -15,6 +15,7 @@ import { Random } from '@rocket.chat/random';
import { Match, check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { dispatchInquiryPosition } from '../../../../ee/app/livechat-enterprise/server/lib/Helper';
import { callbacks } from '../../../../lib/callbacks';
import { sendNotification } from '../../../lib/server';
import {
@ -27,6 +28,7 @@ import { i18n } from '../../../utils/lib/i18n';
import { createLivechatRoom, createLivechatInquiry, allowAgentSkipQueue } from './Helper';
import { Livechat } from './LivechatTyped';
import { RoutingManager } from './RoutingManager';
import { getInquirySortMechanismSetting } from './settings';
const logger = new Logger('QueueManager');
@ -259,6 +261,18 @@ export class QueueManager {
throw new Error('room-not-found');
}
if (!newRoom.servedBy && settings.get('Omnichannel_calculate_dispatch_service_queue_statistics')) {
const [inq] = await LivechatInquiry.getCurrentSortedQueueAsync({
inquiryId: inquiry._id,
department,
queueSortBy: getInquirySortMechanismSetting(),
});
if (inq) {
void dispatchInquiryPosition(inq);
}
}
return newRoom;
}

@ -107,15 +107,11 @@ export const dispatchInquiryPosition = async (inquiry: Omit<InquiryWithAgentInfo
return;
}
const data = await normalizeQueueInfo({ position, queueInfo, department });
const propagateInquiryPosition = (inquiry: Omit<InquiryWithAgentInfo, 'v'>) => {
return setTimeout(() => {
void api.broadcast('omnichannel.room', inquiry.rid, {
type: 'queueData',
data,
});
};
return setTimeout(() => {
propagateInquiryPosition(inquiry);
}, 1000);
};

Loading…
Cancel
Save