From e41635c3f12143db0786a953f01ac956cdc5fe72 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Thu, 3 Oct 2024 20:07:07 +0530 Subject: [PATCH] chore!: removed deprecated methods livechat:removeAgent, livechat:removeManager, and livechat:removeDepartment Signed-off-by: Abhinav Kumar --- .changeset/purple-tools-heal.md | 5 +++ apps/meteor/app/livechat/server/index.ts | 3 -- .../livechat/server/methods/removeAgent.ts | 27 --------------- .../server/methods/removeDepartment.ts | 33 ------------------- .../livechat/server/methods/removeManager.ts | 29 ---------------- 5 files changed, 5 insertions(+), 92 deletions(-) create mode 100644 .changeset/purple-tools-heal.md delete mode 100644 apps/meteor/app/livechat/server/methods/removeAgent.ts delete mode 100644 apps/meteor/app/livechat/server/methods/removeDepartment.ts delete mode 100644 apps/meteor/app/livechat/server/methods/removeManager.ts diff --git a/.changeset/purple-tools-heal.md b/.changeset/purple-tools-heal.md new file mode 100644 index 000000000000..069703865c4d --- /dev/null +++ b/.changeset/purple-tools-heal.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removed deprecated methods `livechat:removeAgent`, `livechat:removeManager` and `livechat:removeDepartment`. Moving forward, use `livechat/users/agent/:_id`, and `livechat/users/manager/:_id` and `livechat/department/:_id` respectively.` diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index 38462ef56c84..782a6db70ef7 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -28,11 +28,8 @@ import './methods/getNextAgent'; import './methods/getRoutingConfig'; import './methods/pageVisited'; import './methods/registerGuest'; -import './methods/removeAgent'; import './methods/removeAllClosedRooms'; import './methods/removeCustomField'; -import './methods/removeDepartment'; -import './methods/removeManager'; import './methods/removeTrigger'; import './methods/removeRoom'; import './methods/saveAgentInfo'; diff --git a/apps/meteor/app/livechat/server/methods/removeAgent.ts b/apps/meteor/app/livechat/server/methods/removeAgent.ts deleted file mode 100644 index ebb57383784f..000000000000 --- a/apps/meteor/app/livechat/server/methods/removeAgent.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { Meteor } from 'meteor/meteor'; - -import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { Livechat } from '../lib/LivechatTyped'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:removeAgent'(username: string): boolean; - } -} - -Meteor.methods({ - async 'livechat:removeAgent'(username) { - methodDeprecationLogger.method('livechat:removeAgent', '7.0.0'); - const uid = Meteor.userId(); - if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-agents'))) { - throw new Meteor.Error('error-not-allowed', 'Not allowed', { - method: 'livechat:removeAgent', - }); - } - - return Livechat.removeAgent(username); - }, -}); diff --git a/apps/meteor/app/livechat/server/methods/removeDepartment.ts b/apps/meteor/app/livechat/server/methods/removeDepartment.ts deleted file mode 100644 index 6e4b11c836f6..000000000000 --- a/apps/meteor/app/livechat/server/methods/removeDepartment.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; -import type { DeleteResult } from 'mongodb'; - -import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { DepartmentHelper } from '../lib/Departments'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:removeDepartment'(_id: string): DeleteResult; - } -} - -Meteor.methods({ - async 'livechat:removeDepartment'(_id) { - methodDeprecationLogger.method('livechat:removeDepartment', '7.0.0'); - - check(_id, String); - - const uid = Meteor.userId(); - - if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-departments'))) { - throw new Meteor.Error('error-not-allowed', 'Not allowed', { - method: 'livechat:removeDepartment', - }); - } - - return DepartmentHelper.removeDepartment(_id); - }, -}); diff --git a/apps/meteor/app/livechat/server/methods/removeManager.ts b/apps/meteor/app/livechat/server/methods/removeManager.ts deleted file mode 100644 index 85a5f3076c8c..000000000000 --- a/apps/meteor/app/livechat/server/methods/removeManager.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { Meteor } from 'meteor/meteor'; - -import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { Livechat } from '../lib/LivechatTyped'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:removeManager'(username: string): boolean; - } -} - -Meteor.methods({ - async 'livechat:removeManager'(username) { - methodDeprecationLogger.method('livechat:removeManager', '7.0.0'); - - const uid = Meteor.userId(); - - if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-managers'))) { - throw new Meteor.Error('error-not-allowed', 'Not allowed', { - method: 'livechat:removeManager', - }); - } - - return Livechat.removeManager(username); - }, -});