From 52762599a7a6c1178bd9afaa53fc3c2a350e0b13 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Wed, 2 Oct 2024 00:09:30 +0530 Subject: [PATCH] chore!: remove deprecated livechat:searchAgent method (#33373) Signed-off-by: Abhinav Kumar Co-authored-by: Guilherme Gazzo --- .changeset/forty-needles-sit.md | 5 +++ apps/meteor/app/livechat/server/index.ts | 1 - .../livechat/server/methods/searchAgent.ts | 45 ------------------- 3 files changed, 5 insertions(+), 46 deletions(-) create mode 100644 .changeset/forty-needles-sit.md delete mode 100644 apps/meteor/app/livechat/server/methods/searchAgent.ts diff --git a/.changeset/forty-needles-sit.md b/.changeset/forty-needles-sit.md new file mode 100644 index 0000000000000..f3a0e160c9fa6 --- /dev/null +++ b/.changeset/forty-needles-sit.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +This adjustment removes the deprecated method `livechat:searchAgent`. Moving forward, use `livechat/users/agent/:_id` endpoint. diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index 37a7705136ec3..7716abcf80dec 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -46,7 +46,6 @@ import './methods/saveInfo'; import './methods/saveIntegration'; import './methods/saveSurveyFeedback'; import './methods/saveTrigger'; -import './methods/searchAgent'; import './methods/sendMessageLivechat'; import './methods/sendFileLivechatMessage'; import './methods/sendOfflineMessage'; diff --git a/apps/meteor/app/livechat/server/methods/searchAgent.ts b/apps/meteor/app/livechat/server/methods/searchAgent.ts deleted file mode 100644 index 932eb51e89d66..0000000000000 --- a/apps/meteor/app/livechat/server/methods/searchAgent.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type { IUser } from '@rocket.chat/core-typings'; -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { Users } from '@rocket.chat/models'; -import { Meteor } from 'meteor/meteor'; - -import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:searchAgent'(username: string): { _id: string; username?: string } | undefined; - } -} - -Meteor.methods({ - async 'livechat:searchAgent'(username) { - methodDeprecationLogger.method('livechat:searchAgent', '7.0.0'); - - const uid = Meteor.userId(); - if (!uid || !(await hasPermissionAsync(uid, 'view-livechat-manager'))) { - throw new Meteor.Error('error-not-allowed', 'Not allowed', { - method: 'livechat:searchAgent', - }); - } - - if (!username || typeof username.valueOf() !== 'string') { - throw new Meteor.Error('error-invalid-arguments', 'Invalid arguments', { - method: 'livechat:searchAgent', - }); - } - - const user = await Users.findOneByUsernameIgnoringCase>(username, { - projection: { _id: 1, username: 1 }, - }); - - if (!user) { - throw new Meteor.Error('error-invalid-user', 'Invalid user', { - method: 'livechat:searchAgent', - }); - } - - return user; - }, -});