chore!: remove deprecated getUserRoles method (#36851)

This commit is contained in:
Abhinav Kumar 2025-09-01 21:40:16 +05:30 committed by Guilherme Gazzo
parent d8044523a4
commit 5664c0c390
4 changed files with 5 additions and 76 deletions

View File

@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': major
---
Removes the deprecated `getUserRoles` method in favor of the `/v1/roles.getUsersInPublicRoles` endpoint.

View File

@ -27,7 +27,6 @@ import './methods/getSingleMessage';
import './methods/getMessages';
import './methods/getSlashCommandPreviews';
import './methods/getUsernameSuggestion';
import './methods/getUserRoles';
import './methods/joinDefaultChannels';
import './methods/joinRoom';
import './methods/leaveRoom';

View File

@ -1,29 +0,0 @@
import { Authorization } from '@rocket.chat/core-services';
import type { IUser } from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Meteor } from 'meteor/meteor';
import { methodDeprecationLogger } from '../lib/deprecationWarningLogger';
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
getUserRoles(): Pick<IUser, '_id' | 'roles' | 'username'>[];
}
}
Meteor.methods<ServerMethods>({
async getUserRoles() {
methodDeprecationLogger.method(
'getUserRoles',
'8.0.0',
'This method is deprecated and will be removed in the future. Use the /v1/roles.getUsersInPublicRoles endpoint instead.',
);
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getUserRoles' });
}
return Authorization.getUsersFromPublicRoles();
},
});

View File

@ -1339,52 +1339,6 @@ describe('Meteor.methods', () => {
});
});
describe('[@getUserRoles]', () => {
it('should fail if not logged in', (done) => {
void request
.post(methodCall('getUserRoles'))
.send({
message: JSON.stringify({
method: 'getUserRoles',
params: [],
id: 'id',
msg: 'method',
}),
})
.expect('Content-Type', 'application/json')
.expect(401)
.expect((res) => {
expect(res.body).to.have.property('status', 'error');
expect(res.body).to.have.property('message');
})
.end(done);
});
it('should return the roles for the current user', (done) => {
void request
.post(methodCall('getUserRoles'))
.set(credentials)
.send({
message: JSON.stringify({
method: 'getUserRoles',
params: [],
id: 'id',
msg: 'method',
}),
})
.expect('Content-Type', 'application/json')
.expect(200)
.expect((res) => {
expect(res.body).to.have.a.property('success', true);
expect(res.body).to.have.a.property('message').that.is.a('string');
const data = JSON.parse(res.body.message);
expect(data).to.have.a.property('result').that.is.an('array');
})
.end(done);
});
});
describe('[@listCustomUserStatus]', () => {
it('should fail if not logged in', (done) => {
void request