From fd72657e8666474307cd057ab0669dc086594489 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Fri, 3 Oct 2025 14:56:18 -0300 Subject: [PATCH 01/11] chore: adds deprecation warning to legacy method --- .../ee/app/livechat-enterprise/server/methods/removeTag.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts b/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts index 775194dc09c7a..42b818a1a6960 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts @@ -3,6 +3,7 @@ import { check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { hasPermissionAsync } from '../../../../../app/authorization/server/functions/hasPermission'; +import { methodDeprecationLogger } from '../../../../../app/lib/server/lib/deprecationWarningLogger'; import { LivechatEnterprise } from '../lib/LivechatEnterprise'; declare module '@rocket.chat/ddp-client' { @@ -14,6 +15,7 @@ declare module '@rocket.chat/ddp-client' { Meteor.methods({ async 'livechat:removeTag'(id) { + methodDeprecationLogger.method('livechat:removeTag', '8.0.0', '/v1/livechat/tags.remove'); const uid = Meteor.userId(); if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-tags'))) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:removeTag' }); From e06b4f26aadf05143444d77f86eedba2025d8f8d Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Fri, 3 Oct 2025 14:56:47 -0300 Subject: [PATCH 02/11] chore: adds new endpoint to replace legacy method livechat:removeTag --- .../livechat-enterprise/server/api/tags.ts | 46 +++++++++++++++++++ packages/rest-typings/src/v1/omnichannel.ts | 30 ++++++++++++ 2 files changed, 76 insertions(+) diff --git a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts index d9506c24aa5d1..78da9c8723204 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts @@ -1,6 +1,15 @@ import { findTags, findTagById } from './lib/tags'; import { API } from '../../../../../app/api/server'; +import type { ExtractRoutesFromAPI } from '../../../../../app/api/server/ApiClass'; import { getPaginationItems } from '../../../../../app/api/server/helpers/getPaginationItems'; +import { + isPOSTLivechatTagsRemoveParams, + POSTLivechatTagsRemoveSuccessResponse, + validateBadRequestErrorResponse, + validateForbiddenErrorResponse, + validateUnauthorizedErrorResponse, +} from '@rocket.chat/rest-typings'; +import { LivechatEnterprise } from '/ee/app/livechat-enterprise/server/lib/LivechatEnterprise'; API.v1.addRoute( 'livechat/tags', @@ -56,3 +65,40 @@ API.v1.addRoute( }, }, ); + +const livechatTagsEndpoints = API.v1.post( + 'livechat/tags.remove', + { + response: { + 200: POSTLivechatTagsRemoveSuccessResponse, + 400: validateBadRequestErrorResponse, + 401: validateUnauthorizedErrorResponse, + 403: validateForbiddenErrorResponse, + }, + authRequired: true, + permissions: ['manage-livechat-tags'], + license: ['livechat-enterprise'], + body: isPOSTLivechatTagsRemoveParams, + }, + async function action() { + const { id } = this.bodyParams; + try { + await LivechatEnterprise.removeTag(id); + + return API.v1.success(); + } catch (error: unknown) { + if (error instanceof Meteor.Error) { + return API.v1.failure(error.reason); + } + + return API.v1.failure('error-removing-tag'); + } + }, +); + +type LivechatTagsEndpoints = ExtractRoutesFromAPI; + +declare module '@rocket.chat/rest-typings' { + // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface + interface Endpoints extends LivechatTagsEndpoints {} +} diff --git a/packages/rest-typings/src/v1/omnichannel.ts b/packages/rest-typings/src/v1/omnichannel.ts index 164c5624000eb..37f39e3c407dc 100644 --- a/packages/rest-typings/src/v1/omnichannel.ts +++ b/packages/rest-typings/src/v1/omnichannel.ts @@ -513,6 +513,36 @@ const LivechatMonitorsListSchema = { export const isLivechatMonitorsListProps = ajv.compile(LivechatMonitorsListSchema); +type POSTLivechatTagsRemoveParams = { + id: string; +}; + +const POSTLivechatTagsRemoveSchema = { + type: 'object', + properties: { + id: { + type: 'string', + }, + }, + required: ['id'], + additionalProperties: false, +}; + +export const isPOSTLivechatTagsRemoveParams = ajv.compile(POSTLivechatTagsRemoveSchema); + +const POSTLivechatTagsRemoveSuccessResponseSchema = { + type: 'object', + properties: { + success: { + type: 'boolean', + enum: [true], + }, + }, + additionalProperties: false, +}; + +export const POSTLivechatTagsRemoveSuccessResponse = ajv.compile(POSTLivechatTagsRemoveSuccessResponseSchema); + type LivechatTagsListProps = PaginatedRequest<{ text: string; viewAll?: 'true' | 'false'; department?: string }, 'name'>; const LivechatTagsListSchema = { From cb8a6bc40f8f52cce77ef402afcb6ce6f6bc2ca0 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Fri, 3 Oct 2025 14:57:08 -0300 Subject: [PATCH 03/11] chore: replaces legacy method use for the new endpoint livechat/tags.remove --- apps/meteor/client/omnichannel/tags/useRemoveTag.tsx | 7 ++++--- apps/meteor/tests/e2e/utils/omnichannel/tags.ts | 5 +---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx b/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx index 3b35cdd88b106..397fb4a7f4cf8 100644 --- a/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx +++ b/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx @@ -1,6 +1,6 @@ import { useEffectEvent } from '@rocket.chat/fuselage-hooks'; import { GenericModal } from '@rocket.chat/ui-client'; -import { useSetModal, useToastMessageDispatch, useRouter, useMethod } from '@rocket.chat/ui-contexts'; +import { useSetModal, useToastMessageDispatch, useRouter, useEndpoint } from '@rocket.chat/ui-contexts'; import { useQueryClient } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; @@ -8,14 +8,15 @@ export const useRemoveTag = () => { const { t } = useTranslation(); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); - const removeTag = useMethod('livechat:removeTag'); + // const removeTag = useMethod('livechat:removeTag'); + const removeTag = useEndpoint('POST', '/v1/livechat/tags.remove'); const queryClient = useQueryClient(); const router = useRouter(); const handleDeleteTag = useEffectEvent((tagId: string) => { const handleDelete = async () => { try { - await removeTag(tagId); + await removeTag({ id: tagId }); dispatchToastMessage({ type: 'success', message: t('Tag_removed') }); router.navigate('/omnichannel/tags'); queryClient.invalidateQueries({ diff --git a/apps/meteor/tests/e2e/utils/omnichannel/tags.ts b/apps/meteor/tests/e2e/utils/omnichannel/tags.ts index ba2a6b43e4d21..9a4d647d95fd2 100644 --- a/apps/meteor/tests/e2e/utils/omnichannel/tags.ts +++ b/apps/meteor/tests/e2e/utils/omnichannel/tags.ts @@ -10,10 +10,7 @@ type CreateTagParams = { departments?: { departmentId: string }[]; }; -const removeTag = async (api: BaseTest['api'], id: string) => - api.post('/method.call/omnichannel:removeTag', { - message: JSON.stringify({ msg: 'method', id: '33', method: 'livechat:removeTag', params: [id] }), - }); +const removeTag = async (api: BaseTest['api'], id: string) => api.post('/livechat/tags.remove', { id }); export const createTag = async (api: BaseTest['api'], { id = null, name, description = '', departments = [] }: CreateTagParams = {}) => { const response = await api.post('/method.call/livechat:saveTag', { From 6186a03485dd75dba318e64194935c66c73b2281 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Fri, 3 Oct 2025 15:00:27 -0300 Subject: [PATCH 04/11] docs: adds changeset --- .changeset/shaggy-clocks-allow.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/shaggy-clocks-allow.md diff --git a/.changeset/shaggy-clocks-allow.md b/.changeset/shaggy-clocks-allow.md new file mode 100644 index 0000000000000..b422d07d913e6 --- /dev/null +++ b/.changeset/shaggy-clocks-allow.md @@ -0,0 +1,6 @@ +--- +"@rocket.chat/meteor": patch +"@rocket.chat/rest-typings": patch +--- + +Adds deprecation warning on `livechat:removeTag` with new endpoint replacing it; `livechat/tags.remove` From 0d736db6fd89cb74f9b7daaf11577ce75a9daec0 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Mon, 6 Oct 2025 14:25:53 -0300 Subject: [PATCH 05/11] fix: eslint errors --- apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts index 78da9c8723204..0d03e67990635 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts @@ -2,6 +2,7 @@ import { findTags, findTagById } from './lib/tags'; import { API } from '../../../../../app/api/server'; import type { ExtractRoutesFromAPI } from '../../../../../app/api/server/ApiClass'; import { getPaginationItems } from '../../../../../app/api/server/helpers/getPaginationItems'; + import { isPOSTLivechatTagsRemoveParams, POSTLivechatTagsRemoveSuccessResponse, @@ -9,7 +10,8 @@ import { validateForbiddenErrorResponse, validateUnauthorizedErrorResponse, } from '@rocket.chat/rest-typings'; -import { LivechatEnterprise } from '/ee/app/livechat-enterprise/server/lib/LivechatEnterprise'; + +import { LivechatEnterprise } from '../lib/LivechatEnterprise'; API.v1.addRoute( 'livechat/tags', From ea670627327bd2a20cc5e5ed29fdd74c724c625b Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Tue, 7 Oct 2025 12:25:17 -0300 Subject: [PATCH 06/11] fix: import order --- .../ee/app/livechat-enterprise/server/api/tags.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts index 0d03e67990635..f5c95dbdd94b4 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts @@ -1,8 +1,3 @@ -import { findTags, findTagById } from './lib/tags'; -import { API } from '../../../../../app/api/server'; -import type { ExtractRoutesFromAPI } from '../../../../../app/api/server/ApiClass'; -import { getPaginationItems } from '../../../../../app/api/server/helpers/getPaginationItems'; - import { isPOSTLivechatTagsRemoveParams, POSTLivechatTagsRemoveSuccessResponse, @@ -11,6 +6,11 @@ import { validateUnauthorizedErrorResponse, } from '@rocket.chat/rest-typings'; +import { findTags, findTagById } from './lib/tags'; +import { API } from '../../../../../app/api/server'; +import type { ExtractRoutesFromAPI } from '../../../../../app/api/server/ApiClass'; +import { getPaginationItems } from '../../../../../app/api/server/helpers/getPaginationItems'; + import { LivechatEnterprise } from '../lib/LivechatEnterprise'; API.v1.addRoute( From ba86dc7f9a36359041b938d0bba11a33d318e398 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Tue, 7 Oct 2025 12:25:55 -0300 Subject: [PATCH 07/11] chore: removes commented code --- apps/meteor/client/omnichannel/tags/useRemoveTag.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx b/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx index 397fb4a7f4cf8..a724de4f8f9ce 100644 --- a/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx +++ b/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx @@ -8,7 +8,6 @@ export const useRemoveTag = () => { const { t } = useTranslation(); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); - // const removeTag = useMethod('livechat:removeTag'); const removeTag = useEndpoint('POST', '/v1/livechat/tags.remove'); const queryClient = useQueryClient(); const router = useRouter(); From 871d0a7f3c31d1f4d0e04c829108d53e5ddea1ff Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Tue, 7 Oct 2025 14:40:43 -0300 Subject: [PATCH 08/11] fix: import order rules --- apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts index f5c95dbdd94b4..362343e7f2a92 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts @@ -10,7 +10,6 @@ import { findTags, findTagById } from './lib/tags'; import { API } from '../../../../../app/api/server'; import type { ExtractRoutesFromAPI } from '../../../../../app/api/server/ApiClass'; import { getPaginationItems } from '../../../../../app/api/server/helpers/getPaginationItems'; - import { LivechatEnterprise } from '../lib/LivechatEnterprise'; API.v1.addRoute( From cb00d6c54cfa7e81419ce8d3557f8876b2a4383a Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Tue, 7 Oct 2025 14:53:28 -0300 Subject: [PATCH 09/11] chore: adds i18n for the error-removing-tag message --- packages/i18n/src/locales/en.i18n.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index 8afb816dc0407..9f2a70455bb66 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -6217,6 +6217,7 @@ "error-invalid-user": "Invalid user", "error-invalid-username": "Invalid username", "error-invalid-value": "Invalid value", + "error-removing-tag": "Error removing tag", "error-invalid-webhook-response": "The webhook URL responded with a status other than 200", "error-license-user-limit-reached": "The maximum number of users has been reached.", "error-loading-extension-list": "Failed to load extension list", @@ -7062,4 +7063,4 @@ "UNVERIFIED": "User is unverified", "UNABLE_TO_VERIFY": "Unable to verify user", "Users_invited": "The users have been invited" -} \ No newline at end of file +} From f396da026d9bfe06aa060f338e8fe40661c18e7d Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Wed, 8 Oct 2025 17:54:41 -0300 Subject: [PATCH 10/11] chore: renames endpoint to match defined patterns --- apps/meteor/client/omnichannel/tags/useRemoveTag.tsx | 2 +- apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts | 2 +- .../ee/app/livechat-enterprise/server/methods/removeTag.ts | 2 +- apps/meteor/tests/e2e/utils/omnichannel/tags.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx b/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx index a724de4f8f9ce..9864e0801861c 100644 --- a/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx +++ b/apps/meteor/client/omnichannel/tags/useRemoveTag.tsx @@ -8,7 +8,7 @@ export const useRemoveTag = () => { const { t } = useTranslation(); const setModal = useSetModal(); const dispatchToastMessage = useToastMessageDispatch(); - const removeTag = useEndpoint('POST', '/v1/livechat/tags.remove'); + const removeTag = useEndpoint('POST', '/v1/livechat/tags.delete'); const queryClient = useQueryClient(); const router = useRouter(); diff --git a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts index 362343e7f2a92..ddaec18bd5063 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/api/tags.ts @@ -68,7 +68,7 @@ API.v1.addRoute( ); const livechatTagsEndpoints = API.v1.post( - 'livechat/tags.remove', + 'livechat/tags.delete', { response: { 200: POSTLivechatTagsRemoveSuccessResponse, diff --git a/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts b/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts index 42b818a1a6960..9e97eadaa1a9c 100644 --- a/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts +++ b/apps/meteor/ee/app/livechat-enterprise/server/methods/removeTag.ts @@ -15,7 +15,7 @@ declare module '@rocket.chat/ddp-client' { Meteor.methods({ async 'livechat:removeTag'(id) { - methodDeprecationLogger.method('livechat:removeTag', '8.0.0', '/v1/livechat/tags.remove'); + methodDeprecationLogger.method('livechat:removeTag', '8.0.0', '/v1/livechat/tags.delete'); const uid = Meteor.userId(); if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-tags'))) { throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:removeTag' }); diff --git a/apps/meteor/tests/e2e/utils/omnichannel/tags.ts b/apps/meteor/tests/e2e/utils/omnichannel/tags.ts index 9a4d647d95fd2..a1289d84e8570 100644 --- a/apps/meteor/tests/e2e/utils/omnichannel/tags.ts +++ b/apps/meteor/tests/e2e/utils/omnichannel/tags.ts @@ -10,7 +10,7 @@ type CreateTagParams = { departments?: { departmentId: string }[]; }; -const removeTag = async (api: BaseTest['api'], id: string) => api.post('/livechat/tags.remove', { id }); +const removeTag = async (api: BaseTest['api'], id: string) => api.post('/livechat/tags.delete', { id }); export const createTag = async (api: BaseTest['api'], { id = null, name, description = '', departments = [] }: CreateTagParams = {}) => { const response = await api.post('/method.call/livechat:saveTag', { From 3b70031dabc813b67b1339c48ae9a40a13e03ac6 Mon Sep 17 00:00:00 2001 From: Lucas Pelegrino Date: Thu, 9 Oct 2025 11:17:02 -0300 Subject: [PATCH 11/11] fix: rmeoves extra space eof --- packages/i18n/src/locales/en.i18n.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/i18n/src/locales/en.i18n.json b/packages/i18n/src/locales/en.i18n.json index e2c4c337a3b19..3b502373822e8 100644 --- a/packages/i18n/src/locales/en.i18n.json +++ b/packages/i18n/src/locales/en.i18n.json @@ -7069,4 +7069,4 @@ "UNVERIFIED": "User is unverified", "UNABLE_TO_VERIFY": "Unable to verify user", "Users_invited": "The users have been invited" -} +} \ No newline at end of file