From 8cfdc81493c483530b31890909dd87bc1d55d9be Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Fri, 11 Oct 2024 22:07:00 +0530 Subject: [PATCH] chore!: remove deprecated livechat:getNextAgent method (#33426) --- .changeset/large-pillows-brush.md | 5 ++ apps/meteor/app/livechat/server/index.ts | 1 - .../livechat/server/methods/getNextAgent.ts | 49 ------------------- 3 files changed, 5 insertions(+), 50 deletions(-) create mode 100644 .changeset/large-pillows-brush.md delete mode 100644 apps/meteor/app/livechat/server/methods/getNextAgent.ts diff --git a/.changeset/large-pillows-brush.md b/.changeset/large-pillows-brush.md new file mode 100644 index 000000000000..b598126bf105 --- /dev/null +++ b/.changeset/large-pillows-brush.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removed deprecated method `livechat:getNextAgent`. Moving forward, use the `livechat/agent.next/:token` endpoint. diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index be139127aa74..e016ff4115e6 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -20,7 +20,6 @@ import './hooks/afterSaveOmnichannelMessage'; import './methods/changeLivechatStatus'; import './methods/closeRoom'; import './methods/getAnalyticsChartData'; -import './methods/getNextAgent'; import './methods/getRoutingConfig'; import './methods/registerGuest'; import './methods/removeAllClosedRooms'; diff --git a/apps/meteor/app/livechat/server/methods/getNextAgent.ts b/apps/meteor/app/livechat/server/methods/getNextAgent.ts deleted file mode 100644 index f603aeef97f3..000000000000 --- a/apps/meteor/app/livechat/server/methods/getNextAgent.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { ILivechatAgent } from '@rocket.chat/core-typings'; -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { LivechatRooms, Users } from '@rocket.chat/models'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { callbacks } from '../../../../lib/callbacks'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { settings } from '../../../settings/server'; -import { Livechat } from '../lib/LivechatTyped'; -import { RoutingManager } from '../lib/RoutingManager'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:getNextAgent'(params: { - token: string; - department?: string; - }): Promise | undefined | null>; - } -} - -Meteor.methods({ - async 'livechat:getNextAgent'({ token, department }) { - methodDeprecationLogger.method('livechat:getNextAgent', '7.0.0'); - check(token, String); - - const extraQuery = await callbacks.run('livechat.applyRoomRestrictions', {}); - const room = await LivechatRooms.findOpenByVisitorToken(token, {}, extraQuery).toArray(); - - if (room && room.length > 0) { - return; - } - - if (!department) { - const requireDepartment = await Livechat.getRequiredDepartment(); - if (requireDepartment) { - department = requireDepartment._id; - } - } - - const agent = await RoutingManager.getNextAgent(department); - if (!agent) { - return; - } - - return Users.getAgentInfo(agent.agentId, settings.get('Livechat_show_agent_email')); - }, -});