mirror of
https://github.com/RocketChat/Rocket.Chat.git
synced 2025-12-28 06:47:25 +00:00
chore!: remove deprecated getUserRoles method (#36851)
This commit is contained in:
parent
d8044523a4
commit
5664c0c390
5
.changeset/fresh-tables-raise.md
Normal file
5
.changeset/fresh-tables-raise.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'@rocket.chat/meteor': major
|
||||
---
|
||||
|
||||
Removes the deprecated `getUserRoles` method in favor of the `/v1/roles.getUsersInPublicRoles` endpoint.
|
||||
@ -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';
|
||||
|
||||
@ -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();
|
||||
},
|
||||
});
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user