Skip to content

Commit

Permalink
regression: fix dispatchInquiryPosition not being fired on room creat…
Browse files Browse the repository at this point in the history
…ion (#32972)
  • Loading branch information
ggazzo authored Aug 3, 2024
1 parent 46a502c commit a38c342
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 14 additions & 0 deletions apps/meteor/app/livechat/server/lib/QueueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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');

Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 1 addition & 5 deletions apps/meteor/ee/app/livechat-enterprise/server/lib/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit a38c342

Please sign in to comment.