diff --git a/apps/meteor/app/livechat/server/lib/QueueManager.ts b/apps/meteor/app/livechat/server/lib/QueueManager.ts index fb1469bcde8b..2e846bc24d9e 100644 --- a/apps/meteor/app/livechat/server/lib/QueueManager.ts +++ b/apps/meteor/app/livechat/server/lib/QueueManager.ts @@ -33,6 +33,7 @@ import { } from '../../../lib/server/lib/notifyListener'; import { settings } from '../../../settings/server'; import { i18n } from '../../../utils/lib/i18n'; +import { getOmniChatSortQuery } from '../../lib/inquiries'; const logger = new Logger('QueueManager'); @@ -336,7 +337,7 @@ export class QueueManager { const [inq] = await LivechatInquiry.getCurrentSortedQueueAsync({ inquiryId: inquiry._id, department: room.departmentId, - queueSortBy: getInquirySortMechanismSetting(), + queueSortBy: getOmniChatSortQuery(getInquirySortMechanismSetting()), }); if (inq) { diff --git a/apps/meteor/server/services/omnichannel/queue.ts b/apps/meteor/server/services/omnichannel/queue.ts index 29d48b9f1f6b..ed7420e78d99 100644 --- a/apps/meteor/server/services/omnichannel/queue.ts +++ b/apps/meteor/server/services/omnichannel/queue.ts @@ -4,6 +4,7 @@ import { License } from '@rocket.chat/license'; import { LivechatInquiry, LivechatRooms } from '@rocket.chat/models'; import { queueLogger } from './logger'; +import { getOmniChatSortQuery } from '../../../app/livechat/lib/inquiries'; import { dispatchAgentDelegated } from '../../../app/livechat/server/lib/Helper'; import { RoutingManager } from '../../../app/livechat/server/lib/RoutingManager'; import { getInquirySortMechanismSetting } from '../../../app/livechat/server/lib/settings'; @@ -112,7 +113,7 @@ export class OmnichannelQueue implements IOmnichannelQueue { private async checkQueue(queue: string | undefined) { queueLogger.debug(`Processing items for queue ${queue || 'Public'}`); try { - const nextInquiry = await LivechatInquiry.findNextAndLock(getInquirySortMechanismSetting(), queue); + const nextInquiry = await LivechatInquiry.findNextAndLock(getOmniChatSortQuery(getInquirySortMechanismSetting()), queue); if (!nextInquiry) { queueLogger.debug(`No more items for queue ${queue || 'Public'}`); return;