From 47ae23c889a13a88fb46876c1ef8f02827ceaf04 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Fri, 11 Oct 2024 00:06:51 +0530 Subject: [PATCH] chore!: remove deprecated method livechat:setDepartmentForVisitor Signed-off-by: Abhinav Kumar --- .changeset/lemon-tables-nail.md | 5 ++ apps/meteor/app/livechat/server/index.ts | 1 - .../server/methods/setDepartmentForVisitor.ts | 51 ------------------- 3 files changed, 5 insertions(+), 52 deletions(-) create mode 100644 .changeset/lemon-tables-nail.md delete mode 100644 apps/meteor/app/livechat/server/methods/setDepartmentForVisitor.ts diff --git a/.changeset/lemon-tables-nail.md b/.changeset/lemon-tables-nail.md new file mode 100644 index 0000000000000..0a756935f9114 --- /dev/null +++ b/.changeset/lemon-tables-nail.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removes deprecated method `livechat:setDepartmentForVisitor`. Moving forward, use the endpoint `livechat/visitor`. diff --git a/apps/meteor/app/livechat/server/index.ts b/apps/meteor/app/livechat/server/index.ts index be139127aa74e..3eb93b3f08e24 100644 --- a/apps/meteor/app/livechat/server/index.ts +++ b/apps/meteor/app/livechat/server/index.ts @@ -31,7 +31,6 @@ import './methods/saveCustomField'; import './methods/saveDepartment'; import './methods/sendMessageLivechat'; import './methods/sendFileLivechatMessage'; -import './methods/setDepartmentForVisitor'; import './methods/transfer'; import './methods/setUpConnection'; import './methods/takeInquiry'; diff --git a/apps/meteor/app/livechat/server/methods/setDepartmentForVisitor.ts b/apps/meteor/app/livechat/server/methods/setDepartmentForVisitor.ts deleted file mode 100644 index 385f2d9890157..0000000000000 --- a/apps/meteor/app/livechat/server/methods/setDepartmentForVisitor.ts +++ /dev/null @@ -1,51 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { LivechatVisitors, Messages, LivechatRooms } from '@rocket.chat/models'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger'; -import { normalizeTransferredByData } from '../lib/Helper'; -import { Livechat } from '../lib/LivechatTyped'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - 'livechat:setDepartmentForVisitor'({ - roomId, - visitorToken, - departmentId, - }: { - roomId: string; - visitorToken: string; - departmentId: string; - }): boolean; - } -} - -Meteor.methods({ - async 'livechat:setDepartmentForVisitor'({ roomId, visitorToken, departmentId }) { - methodDeprecationLogger.method('livechat:setDepartmentForVisitor', '7.0.0'); - - check(roomId, String); - check(visitorToken, String); - check(departmentId, String); - - const room = await LivechatRooms.findOneById(roomId); - const visitor = await LivechatVisitors.getVisitorByToken(visitorToken); - - if (!room || room.t !== 'l' || !room.v || room.v.token !== visitor?.token) { - throw new Meteor.Error('error-invalid-room', 'Invalid room'); - } - - // update visited page history to not expire - await Messages.keepHistoryForToken(visitorToken); - - const transferData = { - roomId, - departmentId, - transferredBy: normalizeTransferredByData(visitor, room), - }; - - return Livechat.transfer(room, visitor, transferData); - }, -});