From 3ec7793cb3388226248a6e1f3f7ec6c239d15322 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Thu, 10 Oct 2024 01:27:55 +0530 Subject: [PATCH] chore!: remove deprecated endpoint livechat/inquiries.queued (#33453) --- .changeset/sixty-moons-walk.md | 6 ++++ .../livechat/imports/server/rest/inquiries.ts | 34 ------------------- .../end-to-end/api/livechat/05-inquiries.ts | 24 +------------ packages/rest-typings/src/v1/omnichannel.ts | 30 ---------------- 4 files changed, 7 insertions(+), 87 deletions(-) create mode 100644 .changeset/sixty-moons-walk.md diff --git a/.changeset/sixty-moons-walk.md b/.changeset/sixty-moons-walk.md new file mode 100644 index 000000000000..7d7e96b7c16c --- /dev/null +++ b/.changeset/sixty-moons-walk.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/rest-typings': major +'@rocket.chat/meteor': major +--- + +Removes deprecated `livechat/inquiries.queued` endpoint. Moving forward use the `livechat/inquiries.queuedForUser` endpoint. diff --git a/apps/meteor/app/livechat/imports/server/rest/inquiries.ts b/apps/meteor/app/livechat/imports/server/rest/inquiries.ts index 07c69a22d08f..2432e55054f5 100644 --- a/apps/meteor/app/livechat/imports/server/rest/inquiries.ts +++ b/apps/meteor/app/livechat/imports/server/rest/inquiries.ts @@ -3,7 +3,6 @@ import { LivechatInquiry, LivechatDepartment, Users } from '@rocket.chat/models' import { isGETLivechatInquiriesListParams, isPOSTLivechatInquiriesTakeParams, - isGETLivechatInquiriesQueuedParams, isGETLivechatInquiriesQueuedForUserParams, isGETLivechatInquiriesGetOneParams, } from '@rocket.chat/rest-typings'; @@ -69,39 +68,6 @@ API.v1.addRoute( }, ); -API.v1.addRoute( - 'livechat/inquiries.queued', - { - authRequired: true, - permissionsRequired: ['view-l-room'], - validateParams: isGETLivechatInquiriesQueuedParams, - deprecation: { - version: '7.0.0', - alternatives: ['livechat/inquiries.queuedForUser'], - }, - }, - { - async get() { - const { offset, count } = await getPaginationItems(this.queryParams); - const { sort } = await this.parseJsonQuery(); - const { department } = this.queryParams; - - return API.v1.success( - await findInquiries({ - userId: this.userId, - department, - status: LivechatInquiryStatus.QUEUED, - pagination: { - offset, - count, - sort, - }, - }), - ); - }, - }, -); - API.v1.addRoute( 'livechat/inquiries.queuedForUser', { authRequired: true, permissionsRequired: ['view-l-room'], validateParams: isGETLivechatInquiriesQueuedForUserParams }, diff --git a/apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts b/apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts index 0039a6c245b0..45f20686f80e 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts +++ b/apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts @@ -52,28 +52,6 @@ describe('LIVECHAT - inquiries', () => { }); }); - describe('livechat/inquiries.queued', () => { - it('should return an "unauthorized error" when the user does not have the necessary permission', async () => { - await updatePermission('view-l-room', []); - await request.get(api('livechat/inquiries.queued')).set(credentials).expect('Content-Type', 'application/json').expect(403); - }); - it('should return an array of inquiries', async () => { - await updatePermission('view-l-room', ['admin']); - await request - .get(api('livechat/inquiries.queued')) - .set(credentials) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res: Response) => { - expect(res.body).to.have.property('success', true); - expect(res.body.inquiries).to.be.an('array'); - expect(res.body).to.have.property('offset'); - expect(res.body).to.have.property('total'); - expect(res.body).to.have.property('count'); - }); - }); - }); - describe('livechat/inquiries.getOne', () => { it('should return an "unauthorized error" when the user does not have the necessary permission', async () => { await updatePermission('view-l-room', []); @@ -235,7 +213,7 @@ describe('LIVECHAT - inquiries', () => { }); it('should return an "unauthorized error" when the user does not have the necessary permission', async () => { await updatePermission('view-l-room', []); - await request.get(api('livechat/inquiries.queued')).set(credentials).expect('Content-Type', 'application/json').expect(403); + await request.get(api('livechat/inquiries.queuedForUser')).set(credentials).expect('Content-Type', 'application/json').expect(403); }); it('should return an array of inquiries', async () => { await restorePermissionToRoles('view-l-room'); diff --git a/packages/rest-typings/src/v1/omnichannel.ts b/packages/rest-typings/src/v1/omnichannel.ts index 09c021a4e7d9..82df994de1ba 100644 --- a/packages/rest-typings/src/v1/omnichannel.ts +++ b/packages/rest-typings/src/v1/omnichannel.ts @@ -2947,33 +2947,6 @@ const POSTLivechatInquiriesTakeParamsSchema = { export const isPOSTLivechatInquiriesTakeParams = ajv.compile(POSTLivechatInquiriesTakeParamsSchema); -type GETLivechatInquiriesQueuedParams = PaginatedRequest<{ department?: string }>; - -const GETLivechatInquiriesQueuedParamsSchema = { - type: 'object', - properties: { - count: { - type: 'number', - nullable: true, - }, - offset: { - type: 'number', - nullable: true, - }, - sort: { - type: 'string', - nullable: true, - }, - department: { - type: 'string', - nullable: true, - }, - }, - additionalProperties: false, -}; - -export const isGETLivechatInquiriesQueuedParams = ajv.compile(GETLivechatInquiriesQueuedParamsSchema); - type GETLivechatInquiriesQueuedForUserParams = PaginatedRequest<{ department?: string }>; const GETLivechatInquiriesQueuedForUserParamsSchema = { @@ -3937,9 +3910,6 @@ export type OmnichannelEndpoints = { '/v1/livechat/inquiries.take': { POST: (params: POSTLivechatInquiriesTakeParams) => { inquiry: ILivechatInquiryRecord }; }; - '/v1/livechat/inquiries.queued': { - GET: (params: GETLivechatInquiriesQueuedParams) => PaginatedResult<{ inquiries: ILivechatInquiryRecord[] }>; - }; '/v1/livechat/inquiries.queuedForUser': { GET: (params: GETLivechatInquiriesQueuedForUserParams) => PaginatedResult<{ inquiries: ILivechatInquiryRecord[] }>; };