-
Notifications
You must be signed in to change notification settings - Fork 341
Description
The internal getUserRoles method call in EmbeddedChatApi fails when connected to modern Rocket.Chat workspaces. The request returns a 400 Bad Request in the browser console, while the underlying server response indicates a 404 Method Not Found error.
As a result, the application is unable to correctly determine user roles (such as admin), which impacts permission-based UI features.
Reproduction Steps
-
Connect EmbeddedChat to a modern Rocket.Chat workspace (tested on a local custom workspace).
-
Log in as any user (including an admin).
-
Open the browser developer console.
-
Observe the following error:
POST http://<host>/api/v1/method.call/getUserRoles 400 (Bad Request) -
Inspect the network response to view the underlying Meteor error.
Actual Behavior
The request to api/v1/method.call/getUserRoles returns the following response:
{
"message": "{\"msg\":\"result\",\"id\":\"\",\"error\":{\"isClientSafe\":true,\"error\":404,\"reason\":\"Method 'getUserRoles' not found\",\"message\":\"Method 'getUserRoles' not found [404]\",\"errorType\":\"Meteor.Error\"}}",
"success": false
}Expected Behavior
The application should successfully fetch the authenticated user’s roles using an API endpoint supported by current Rocket.Chat versions.
Technical Context
The issue originates in EmbeddedChatApi.ts:
async getUserRoles() {
try {
const { userId, authToken } = (await this.auth.getCurrentUser()) || {};
const response = await fetch(
`${this.host}/api/v1/method.call/getUserRoles`, // Legacy DDP-over-REST method
{
body: JSON.stringify({
message: JSON.stringify({
msg: "method",
id: null,
method: "getUserRoles",
params: [],
}),
}),
// ...
}
);
// ...
}
}Root Cause
The codebase relies on a legacy DDP-over-REST method call (getUserRoles) that has been deprecated or removed in recent Rocket.Chat versions in favor of standard REST API endpoints.
Proposed Fix
Update getUserRoles to use a modern REST API endpoint supported by current Rocket.Chat servers, such as:
GET /api/v1/roles.getUsersInRole?role=admin- or an equivalent roles/permissions endpoint
This change will restore compatibility with modern Rocket.Chat versions and ensure accurate role-based behavior in the UI.