diff --git a/.changeset/remove-canned-responses-delete-endpoint.md b/.changeset/remove-canned-responses-delete-endpoint.md new file mode 100644 index 0000000000000..3857e2ad5d3b5 --- /dev/null +++ b/.changeset/remove-canned-responses-delete-endpoint.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/rest-typings': major +'@rocket.chat/meteor': major +--- + +Removes the deprecated `DELETE /v1/canned-responses` endpoint, which received the canned response id in the request body. Use `DELETE /v1/canned-responses/:_id` instead. diff --git a/apps/meteor/ee/server/api/v1/canned-responses.ts b/apps/meteor/ee/server/api/v1/canned-responses.ts index 05b73baba5ba5..6b8daeca5dbca 100644 --- a/apps/meteor/ee/server/api/v1/canned-responses.ts +++ b/apps/meteor/ee/server/api/v1/canned-responses.ts @@ -1,5 +1,5 @@ import type { ILivechatDepartment, IOmnichannelCannedResponse, IUser } from '@rocket.chat/core-typings'; -import { isPOSTCannedResponsesProps, isCannedResponsesProps, isDELETECannedResponsesProps } from '@rocket.chat/rest-typings'; +import { isPOSTCannedResponsesProps, isCannedResponsesProps } from '@rocket.chat/rest-typings'; import type { PaginatedResult, PaginatedRequest } from '@rocket.chat/rest-typings'; import { API } from '../../../../server/api'; @@ -32,7 +32,6 @@ declare module '@rocket.chat/rest-typings' { tags?: any; departmentId?: ILivechatDepartment['_id']; }) => void; - DELETE: (params: { _id: IOmnichannelCannedResponse['_id'] }) => void; }; '/v1/canned-responses/:_id': { GET: () => { @@ -55,61 +54,13 @@ API.v1.addRoute( }, ); -/** - * @deprecated - * @openapi - * /api/v1/canned-responses: - * delete: - * deprecated: true - * security: - * $ref: '#/security/authenticated' - * parameters: - * - in: body - * name: body - * description: | - * **_id** (required): Canned Response ID to be removed. - * schema: - * type: object - * required: - * - _id - * properties: - * _id: - * type: string - * tags: - * - Canned_Responses - * responses: - * 200: - * description: Successful Response - * schema: - * type: object - * properties: - * status: - * type: string - * example: success - * data: - * type: object - * description: The response data - * properties: - * success: - * type: boolean - * example: true - * 401: - * $ref: '#/responses/Unauthorized' - * 403: - * $ref: '#/responses/Forbidden' - * 404: - * $ref: '#/responses/NotFound' - * 500: - * $ref: '#/responses/InternalServerError' - */ API.v1.addRoute( 'canned-responses', { authRequired: true, - permissionsRequired: { GET: ['view-canned-responses'], POST: ['save-canned-responses'], DELETE: ['remove-canned-responses'] }, - validateParams: { POST: isPOSTCannedResponsesProps, DELETE: isDELETECannedResponsesProps, GET: isCannedResponsesProps }, + permissionsRequired: { GET: ['view-canned-responses'], POST: ['save-canned-responses'] }, + validateParams: { POST: isPOSTCannedResponsesProps, GET: isCannedResponsesProps }, license: ['canned-responses'], - deprecations: { DELETE: { version: '8.0.0', alternatives: ['/v1/canned-responses/:_id'] } }, }, { async get() { @@ -153,12 +104,6 @@ API.v1.addRoute( ); return API.v1.success(); }, - // deprecated - async delete() { - const { _id } = this.bodyParams; - await removeCannedResponse(this.userId, _id); - return API.v1.success(); - }, }, ); diff --git a/apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts b/apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts index fc27b641e713d..697f65b09eb1e 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts +++ b/apps/meteor/tests/end-to-end/api/livechat/15-canned-responses.ts @@ -279,9 +279,9 @@ import { IS_EE } from '../../../e2e/config/constants'; await updatePermission('remove-canned-responses', []); return request.delete(api('canned-responses/sfdads')).set(credentials).expect(403); }); - it('should fail if _id is not on the request', async () => { + it('should fail if canned response does not exist', async () => { await updatePermission('remove-canned-responses', ['livechat-agent', 'livechat-monitor', 'livechat-manager', 'admin']); - return request.delete(api('canned-responses')).set(credentials).expect(400); + return request.delete(api('canned-responses/invalid-id')).set(credentials).expect(400); }); it('should delete a canned response', async () => { const response = await createCannedResponse(); diff --git a/packages/rest-typings/src/v1/omnichannel.ts b/packages/rest-typings/src/v1/omnichannel.ts index e9bcd7778ac26..a24b9a8aa5729 100644 --- a/packages/rest-typings/src/v1/omnichannel.ts +++ b/packages/rest-typings/src/v1/omnichannel.ts @@ -3023,23 +3023,6 @@ const POSTCannedResponsesPropsSchema = { export const isPOSTCannedResponsesProps = ajv.compile(POSTCannedResponsesPropsSchema); -type DELETECannedResponsesProps = { - _id: string; -}; - -const DELETECannedResponsesPropsSchema = { - type: 'object', - properties: { - _id: { - type: 'string', - }, - }, - required: ['_id'], - additionalProperties: false, -}; - -export const isDELETECannedResponsesProps = ajv.compile(DELETECannedResponsesPropsSchema); - type POSTLivechatUsersTypeProps = { username: string; }; @@ -4810,7 +4793,6 @@ export type OmnichannelEndpoints = { cannedResponses: IOmnichannelCannedResponse[]; }>; POST: (params: POSTCannedResponsesProps) => void; - DELETE: (params: DELETECannedResponsesProps) => void; }; '/v1/canned-responses/:_id': {