Skip to content
Snippets Groups Projects
Commit 30e698b7 authored by Abhinav Kumar's avatar Abhinav Kumar Committed by Guilherme Gazzo
Browse files

chore!: removed deprecated method livechat:getAgentData (#33450)

parent cf67f766
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/meteor': major
---
Removes deprecated method `livechat:getAgentData`. Moving forward use the endpoint `livechat/agent.info/:rid/:token`.
......@@ -20,7 +20,6 @@ import './hooks/afterSaveOmnichannelMessage';
import './methods/changeLivechatStatus';
import './methods/closeRoom';
import './methods/discardTranscript';
import './methods/getAgentData';
import './methods/getAgentOverviewData';
import './methods/getAnalyticsChartData';
import './methods/getAnalyticsOverviewData';
......
import type { ILivechatAgent } from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { LivechatVisitors, LivechatRooms, Users } from '@rocket.chat/models';
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
import { settings } from '../../../settings/server';
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
'livechat:getAgentData'(params: {
roomId: string;
token: string;
}): Promise<Pick<ILivechatAgent, '_id' | 'username' | 'name' | 'status' | 'customFields' | 'phone' | 'livechat'> | null | undefined>;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:getAgentData'({ roomId, token }) {
check(roomId, String);
check(token, String);
methodDeprecationLogger.warn(
'The method "livechat:getAgentData" is deprecated and will be removed after version v7.0.0. Use "livechat/agent.info/:rid/:token" instead.',
);
const room = await LivechatRooms.findOneById(roomId);
const visitor = await LivechatVisitors.getVisitorByToken(token);
if (!room || room.t !== 'l' || !room.v || room.v.token !== visitor?.token) {
throw new Meteor.Error('error-invalid-room', 'Invalid room');
}
if (!room.servedBy) {
return;
}
return Users.getAgentInfo(room.servedBy._id, settings.get('Livechat_show_agent_email'));
},
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment