diff --git a/.changeset/thirty-trainers-swim.md b/.changeset/thirty-trainers-swim.md new file mode 100644 index 0000000000000000000000000000000000000000..3e99c3f58b239d5e91b35d9c2b9f57152b426c67 --- /dev/null +++ b/.changeset/thirty-trainers-swim.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removed deprecated methods `livechat:requestTranscript` and `livechat:discardTranscript`. Moving forward use `livechat/transcript/:rid` endpoint's POST and DELETE methods. diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index 993d522f298fca1bf9fe1481576b9eb5f9275144..13eeae4a4e9a409bb633cd70880e9a8257fa88ea 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -19,7 +19,6 @@ import './hooks/afterAgentRemoved'; import './hooks/afterSaveOmnichannelMessage'; import './methods/changeLivechatStatus'; import './methods/closeRoom'; -import './methods/discardTranscript'; import './methods/getAnalyticsChartData'; import './methods/getNextAgent'; import './methods/getRoutingConfig'; @@ -37,7 +36,6 @@ import './methods/setDepartmentForVisitor'; import './methods/transfer'; import './methods/setUpConnection'; import './methods/takeInquiry'; -import './methods/requestTranscript'; import './methods/returnAsInquiry'; import './methods/sendTranscript'; import './methods/getFirstRoomMessage'; diff --git a/apps/meteor/app/livechat/server/methods/discardTranscript.ts b/apps/meteor/app/livechat/server/methods/discardTranscript.ts deleted file mode 100644 index 3265aa9c54d255ed06d7056f2bb5883d1db3c291..0000000000000000000000000000000000000000 --- a/apps/meteor/app/livechat/server/methods/discardTranscript.ts +++ /dev/null @@ -1,49 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { LivechatRooms } from '@rocket.chat/models'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:discardTranscript'(rid: string): boolean; - } -} - -Meteor.methods<ServerMethods>({ - async 'livechat:discardTranscript'(rid: string) { - methodDeprecationLogger.method('livechat:discardTranscript', '7.0.0'); - check(rid, String); - methodDeprecationLogger.warn( - 'The method "livechat:discardTranscript" is deprecated and will be removed after version v7.0.0. Use "livechat/transcript/:rid" (DELETE) instead.', - ); - - const user = Meteor.userId(); - - if (!user || !(await hasPermissionAsync(user, 'send-omnichannel-chat-transcript'))) { - throw new Meteor.Error('error-not-allowed', 'Not allowed', { - method: 'livechat:requestTranscript', - }); - } - - const room = await LivechatRooms.findOneById(rid); - if (!room?.open) { - throw new Meteor.Error('error-invalid-room', 'Invalid room', { - method: 'livechat:discardTranscript', - }); - } - - if (!room.transcriptRequest) { - throw new Meteor.Error('error-transcript-not-requested', 'No transcript requested for this chat', { - method: 'livechat:discardTranscript', - }); - } - - await LivechatRooms.unsetEmailTranscriptRequestedByRoomId(rid); - - return true; - }, -}); diff --git a/apps/meteor/app/livechat/server/methods/requestTranscript.ts b/apps/meteor/app/livechat/server/methods/requestTranscript.ts deleted file mode 100644 index 80cb3a9625fea18aece6b8164eecb780ef3a9a23..0000000000000000000000000000000000000000 --- a/apps/meteor/app/livechat/server/methods/requestTranscript.ts +++ /dev/null @@ -1,45 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { Users } from '@rocket.chat/models'; -import { check } from 'meteor/check'; -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:requestTranscript'(rid: string, email: string, subject: string): Promise<boolean>; - } -} - -Meteor.methods<ServerMethods>({ - async 'livechat:requestTranscript'(rid, email, subject) { - methodDeprecationLogger.method('livechat:requestTranscript', '7.0.0'); - check(rid, String); - check(email, String); - - const userId = Meteor.userId(); - - if (!userId || !(await hasPermissionAsync(userId, 'send-omnichannel-chat-transcript'))) { - throw new Meteor.Error('error-not-allowed', 'Not allowed', { - method: 'livechat:requestTranscript', - }); - } - - const user = await Users.findOneById(userId, { - projection: { _id: 1, username: 1, name: 1, utcOffset: 1 }, - }); - - if (!user) { - throw new Meteor.Error('error-invalid-user', 'Invalid user', { - method: 'livechat:requestTranscript', - }); - } - - await Livechat.requestTranscript({ rid, email, subject, user }); - - 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 4388a4d243417ee649c9d4090d07baeddd52df8f..43454c5115dc9538006b47ae0a82306700f31b6d 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 @@ -2576,15 +2576,11 @@ describe('LIVECHAT - rooms', () => { const { _id } = await createLivechatRoom(visitor.token); // First, request transcript with livechat:requestTranscript method await request - .post(methodCall('livechat:requestTranscript')) + .post(api(`livechat/transcript/${_id}`)) .set(credentials) .send({ - message: JSON.stringify({ - method: 'livechat:requestTranscript', - params: [_id, 'test@test.com', 'Transcript of your omnichannel conversation'], - id: 'id', - msg: 'method', - }), + email: 'test@test.com', + subject: 'Transcript of your omnichannel conversation', }) .expect(200);