From c93c330298317ddad0638e310dcd3aa564525106 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Thu, 10 Oct 2024 01:31:48 +0530 Subject: [PATCH] chore!: removed deprecated method livechat:getAgentData (#33450) --- .changeset/yellow-jobs-serve.md | 5 +++ apps/meteor/app/livechat/server/index.ts | 1 - .../livechat/server/methods/getAgentData.ts | 42 ------------------- 3 files changed, 5 insertions(+), 43 deletions(-) create mode 100644 .changeset/yellow-jobs-serve.md delete mode 100644 apps/meteor/app/livechat/server/methods/getAgentData.ts diff --git a/.changeset/yellow-jobs-serve.md b/.changeset/yellow-jobs-serve.md new file mode 100644 index 000000000000..add05b7704b7 --- /dev/null +++ b/.changeset/yellow-jobs-serve.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removes deprecated method `livechat:getAgentData`. Moving forward use the endpoint `livechat/agent.info/:rid/:token`. diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index d365b8af5a1b..70d756cbc6ef 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/discardTranscript'; -import './methods/getAgentData'; import './methods/getAgentOverviewData'; import './methods/getAnalyticsChartData'; import './methods/getAnalyticsOverviewData'; diff --git a/apps/meteor/app/livechat/server/methods/getAgentData.ts b/apps/meteor/app/livechat/server/methods/getAgentData.ts deleted file mode 100644 index 5fe58560806e..000000000000 --- a/apps/meteor/app/livechat/server/methods/getAgentData.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { ILivechatAgent } from '@rocket.chat/core-typings'; -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { LivechatVisitors, LivechatRooms, Users } from '@rocket.chat/models'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { settings } from '../../../settings/server'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:getAgentData'(params: { - roomId: string; - token: string; - }): Promise | null | undefined>; - } -} - -Meteor.methods({ - async 'livechat:getAgentData'({ roomId, token }) { - check(roomId, String); - check(token, String); - - methodDeprecationLogger.warn( - 'The method "livechat:getAgentData" is deprecated and will be removed after version v7.0.0. Use "livechat/agent.info/:rid/:token" instead.', - ); - - const room = await LivechatRooms.findOneById(roomId); - const visitor = await LivechatVisitors.getVisitorByToken(token); - - if (!room || room.t !== 'l' || !room.v || room.v.token !== visitor?.token) { - throw new Meteor.Error('error-invalid-room', 'Invalid room'); - } - - if (!room.servedBy) { - return; - } - - return Users.getAgentInfo(room.servedBy._id, settings.get('Livechat_show_agent_email')); - }, -});