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

chore!: remove deprecated livechat:searchAgent method (#33373)

parent 06e68a73
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/meteor': major
---
This adjustment removes the deprecated method `livechat:searchAgent`. Moving forward, use `livechat/users/agent/:_id` endpoint.
......@@ -46,7 +46,6 @@ import './methods/saveInfo';
import './methods/saveIntegration';
import './methods/saveSurveyFeedback';
import './methods/saveTrigger';
import './methods/searchAgent';
import './methods/sendMessageLivechat';
import './methods/sendFileLivechatMessage';
import './methods/sendOfflineMessage';
......
import type { IUser } from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Users } from '@rocket.chat/models';
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:searchAgent'(username: string): { _id: string; username?: string } | undefined;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:searchAgent'(username) {
methodDeprecationLogger.method('livechat:searchAgent', '7.0.0');
const uid = Meteor.userId();
if (!uid || !(await hasPermissionAsync(uid, 'view-livechat-manager'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:searchAgent',
});
}
if (!username || typeof username.valueOf() !== 'string') {
throw new Meteor.Error('error-invalid-arguments', 'Invalid arguments', {
method: 'livechat:searchAgent',
});
}
const user = await Users.findOneByUsernameIgnoringCase<Pick<IUser, 'username' | '_id'>>(username, {
projection: { _id: 1, username: 1 },
});
if (!user) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'livechat:searchAgent',
});
}
return user;
},
});
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