diff --git a/.changeset/lemon-tables-nail.md b/.changeset/lemon-tables-nail.md new file mode 100644 index 000000000000..0a756935f911 --- /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 be139127aa74..3eb93b3f08e2 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 385f2d989015..000000000000 --- 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); - }, -});