diff --git a/.changeset/large-pillows-brush.md b/.changeset/large-pillows-brush.md new file mode 100644 index 0000000000000..b598126bf105c --- /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 be139127aa74e..e016ff4115e6c 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 f603aeef97f34..0000000000000 --- 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')); - }, -});