From dad0746ba751d670cf2bbfb0bb93b6c042193b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Jaeger=20Foresti?= <60678893+juliajforesti@users.noreply.github.com> Date: Fri, 7 Nov 2025 11:16:29 -0300 Subject: [PATCH] chore!: remove deprecated `livechat:sendTranscript` method (#37396) --- .changeset/strong-bats-swim.md | 5 + apps/meteor/app/livechat/server/index.ts | 1 - .../livechat/server/methods/sendTranscript.ts | 52 ------ .../tests/end-to-end/api/livechat/00-rooms.ts | 161 +----------------- 4 files changed, 7 insertions(+), 212 deletions(-) create mode 100644 .changeset/strong-bats-swim.md delete mode 100644 apps/meteor/app/livechat/server/methods/sendTranscript.ts diff --git a/.changeset/strong-bats-swim.md b/.changeset/strong-bats-swim.md new file mode 100644 index 00000000000..d0287981e1e --- /dev/null +++ b/.changeset/strong-bats-swim.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removes deprecated `livechat:sendTranscript` method diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index a4d7f2d97ee..0d083b5c4e1 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -19,7 +19,6 @@ import './methods/saveDepartment'; import './methods/sendMessageLivechat'; import './methods/sendFileLivechatMessage'; import './methods/takeInquiry'; -import './methods/sendTranscript'; import './lib/QueueManager'; import './lib/RoutingManager'; import './lib/routing/External'; diff --git a/apps/meteor/app/livechat/server/methods/sendTranscript.ts b/apps/meteor/app/livechat/server/methods/sendTranscript.ts deleted file mode 100644 index a891ed156c5..00000000000 --- a/apps/meteor/app/livechat/server/methods/sendTranscript.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { Omnichannel } from '@rocket.chat/core-services'; -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { LivechatRooms, Users } from '@rocket.chat/models'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; -import { RateLimiter } from '../../../lib/server'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { sendTranscript } from '../lib/sendTranscript'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:sendTranscript'(token: string, rid: string, email: string, subject: string): boolean; - } -} - -Meteor.methods({ - async 'livechat:sendTranscript'(token, rid, email, subject) { - methodDeprecationLogger.method('livechat:sendTranscript', '8.0.0', '/v1/livechat/transcript'); - check(rid, String); - check(email, String); - - const uid = Meteor.userId(); - if (!uid || !(await hasPermissionAsync(uid, 'send-omnichannel-chat-transcript'))) { - throw new Meteor.Error('error-not-allowed', 'Not allowed', { - method: 'livechat:sendTranscript', - }); - } - - const user = await Users.findOneById(uid, { - projection: { _id: 1, username: 1, name: 1, utcOffset: 1 }, - }); - - const room = await LivechatRooms.findOneById(rid, { projection: { activity: 1 } }); - if (!room) { - throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'livechat:sendTranscript' }); - } - if (!(await Omnichannel.isWithinMACLimit(room))) { - throw new Meteor.Error('error-mac-limit-reached', 'MAC limit reached', { method: 'livechat:sendTranscript' }); - } - - return sendTranscript({ token, rid, email, subject, user }); - }, -}); - -RateLimiter.limitMethod('livechat:sendTranscript', 1, 5000, { - connectionId() { - return true; - }, -}); diff --git a/apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts b/apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts index 74b6a29bdbd..6610708eba6 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts +++ b/apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts @@ -19,7 +19,7 @@ import { after, afterEach, before, describe, it } from 'mocha'; import type { Response } from 'supertest'; import type { SuccessResult } from '../../../../app/api/server/definition'; -import { getCredentials, api, request, credentials, methodCall } from '../../../data/api-data'; +import { getCredentials, api, request, credentials } from '../../../data/api-data'; import { apps, APP_URL } from '../../../data/apps/apps-data'; import { createCustomField } from '../../../data/livechat/custom-fields'; import type { OnlineAgent } from '../../../data/livechat/department'; @@ -52,7 +52,7 @@ import { import { saveTags } from '../../../data/livechat/tags'; import { createMonitor, createUnit, deleteUnit } from '../../../data/livechat/units'; import type { DummyResponse } from '../../../data/livechat/utils'; -import { parseMethodResponse, sleep } from '../../../data/livechat/utils'; +import { sleep } from '../../../data/livechat/utils'; import { restorePermissionToRoles, addPermissions, @@ -3630,161 +3630,4 @@ describe('LIVECHAT - rooms', () => { }); }); }); - - describe('livechat:sendTranscript', () => { - describe('with no permission', () => { - before(async () => { - await updatePermission('send-omnichannel-chat-transcript', []); - }); - after(async () => { - await updatePermission('send-omnichannel-chat-transcript', ['admin']); - }); - it('should fail if user doesnt have send-omnichannel-chat-transcript permission', async () => { - const { body } = await request - .post(methodCall('livechat:sendTranscript')) - .set(credentials) - .send({ - message: JSON.stringify({ - msg: 'method', - id: '1091', - method: 'livechat:sendTranscript', - params: ['test', 'test', 'test', 'test'], - }), - }) - .expect(200); - - const result = parseMethodResponse(body); - expect(body.success).to.be.true; - expect(result).to.have.property('error').that.is.an('object').that.has.property('error', 'error-not-allowed'); - }); - }); - it('should fail if not all params are provided', async () => { - const { body } = await request - .post(methodCall('livechat:sendTranscript')) - .set(credentials) - .send({ - message: JSON.stringify({ - msg: 'method', - id: '1091', - method: 'livechat:sendTranscript', - params: [], - }), - }) - .expect(200); - - const result = parseMethodResponse(body); - expect(body.success).to.be.true; - expect(result).to.have.property('error').that.is.an('object').that.has.property('errorType', 'Match.Error'); - }); - it('should fail if token is invalid', async () => { - const { body } = await request - .post(methodCall('livechat:sendTranscript')) - .set(credentials) - .send({ - message: JSON.stringify({ - msg: 'method', - id: '1091', - method: 'livechat:sendTranscript', - params: ['invalid-token', 'test', 'test', 'test'], - }), - }) - .expect(200); - - const result = parseMethodResponse(body); - expect(body.success).to.be.true; - expect(result).to.have.property('error').that.is.an('object'); - }); - it('should fail if roomId is invalid', async () => { - const visitor = await createVisitor(); - const { body } = await request - .post(methodCall('livechat:sendTranscript')) - .set(credentials) - .send({ - message: JSON.stringify({ - msg: 'method', - id: '1091', - method: 'livechat:sendTranscript', - params: [visitor.token, 'invalid-room-id', 'test', 'test'], - }), - }) - .expect(200); - - const result = parseMethodResponse(body); - expect(body.success).to.be.true; - expect(result).to.have.property('error').that.is.an('object'); - await deleteVisitor(visitor.token); - }); - describe('with rooms', () => { - let visitor1: ILivechatVisitor; - let visitor2: ILivechatVisitor; - let room: IOmnichannelRoom; - before(async () => { - visitor1 = await createVisitor(); - visitor2 = await createVisitor(); - room = await createLivechatRoom(visitor1.token); - }); - after(async () => { - await deleteVisitor(visitor1.token); - await deleteVisitor(visitor2.token); - await closeOmnichannelRoom(room._id); - }); - - it('should fail if token is from another conversation', async () => { - const { body } = await request - .post(methodCall('livechat:sendTranscript')) - .set(credentials) - .send({ - message: JSON.stringify({ - msg: 'method', - id: '1091', - method: 'livechat:sendTranscript', - params: [visitor2.token, room._id, 'test', 'test'], - }), - }) - .expect(200); - - const result = parseMethodResponse(body); - expect(body.success).to.be.true; - expect(result).to.have.property('error').that.is.an('object'); - }); - - it('should fail if email provided is invalid', async () => { - const { body } = await request - .post(methodCall('livechat:sendTranscript')) - .set(credentials) - .send({ - message: JSON.stringify({ - msg: 'method', - id: '1091', - method: 'livechat:sendTranscript', - params: [visitor1.token, room._id, 'invalid-email', 'test'], - }), - }) - .expect(200); - - const result = parseMethodResponse(body); - expect(body.success).to.be.true; - expect(result).to.have.property('error').that.is.an('object'); - }); - - it('should work if all params are good', async () => { - const { body } = await request - .post(methodCall('livechat:sendTranscript')) - .set(credentials) - .send({ - message: JSON.stringify({ - msg: 'method', - id: '1091', - method: 'livechat:sendTranscript', - params: [visitor1.token, room._id, 'test@test', 'test'], - }), - }) - .expect(200); - - const result = parseMethodResponse(body); - expect(body.success).to.be.true; - expect(result).to.have.property('result', true); - }); - }); - }); });