Skip to content

getUserRoles only fetches admins, moderator and owner badges never shown #1288

Description

@deepak0x

getUserRoles() in EmbeddedChatApi.ts:671-682 hardcodes a single call to getUsersInRole("admin"). It never fetches moderators or owners. The result feeds into memberStore.admins, which MessageHeader.js:140 checks to show the "Admin" badge — but there's no equivalent for moderator or owner roles, so those badges never render.

async getUserRoles() {
  const response = await this.getUsersInRole("admin");
  if (response && response.success) {
    return { result: response.users };
  }
  return { result: [] };
}

The per-room roles from channels.roles / groups.roles API do get fetched separately and shown via channelLevelRoles in MessageHeader.js:150, so room-scoped roles work. But the global moderator/owner roles are just missing.

Steps to reproduce:

  1. Have a user with the "moderator" or "owner" role in a room
  2. Open EmbeddedChat in that room
  3. Look at messages from that user — no role badge appears
  4. Compare with a user who has "admin" role — the "Admin" badge shows

Expected behavior:

Moderator and owner roles should show badges next to the username, same as admin.

Actual behavior:

Only the "Admin" badge renders. Moderators and owners get no badge because their role data is never fetched.

Code reference:

  • packages/api/src/EmbeddedChatApi.ts:671-682 — only queries admin role
  • packages/react/src/views/Message/MessageHeader.js:140 — only checks admins array

Activity

  1. deepak0x commented on Apr 25, 2026

    @deepak0x
    ContributorAuthor

    @Spiral-Memory found this while going through the role-fetching code. The fix would be to call getUsersInRole for moderator and owner alongside admin, merge the results, and store them in a structure that MessageHeader can check per role type to render the right badge. Happy to pick this up.

  2. amankv1234 commented on Aug 3, 2026

    @amankv1234

    @deepak0x I have already message you in rocket chat channel , that i have already experince in open source contribution and i want to contribute in this project so kindly check message and if possible please assigne this issue i will definitely solve this issue and also provide you rocket.chat communication id so i can communicate with you , I have already setup of this project

  3. Spiral-Memory commented on Aug 3, 2026

    @Spiral-Memory
    Collaborator

    I think @Aryan-Verma-999 has addressed the issue in his previous PR. Can you please confirm

  4. deepak0x commented on Aug 3, 2026

    @deepak0x
    ContributorAuthor

    @Spiral-Memory — checked this. The fix is being handled in PR #1307 ("fix: fetch admin, moderator, and owner roles for message badges") by @vivekyadav-3, not a PR by @Aryan-Verma-999 — I couldn't find any PR from Aryan that touches this role-fetching code.

    PR #1307 updates getUserRoles() in packages/api/src/EmbeddedChatApi.ts to call getUsersInRole for ["admin", "moderator", "owner"], merge and dedupe the results — which directly addresses the root cause described in #1288 (only admin was being fetched).

    Two caveats before we mark #1288 resolved:

    1. PR fix: fetch admin, moderator, and owner roles for message badges #1307 is still open (not merged).
    2. It only changes EmbeddedChatApi.ts. The issue also notes MessageHeader.js only checks admins — so the frontend badge rendering for moderator/owner still needs to be wired up (or confirmed already handled by the merged user list). That part should be verified in review.

    So: the issue is being addressed, but not yet merged/confirmed complete. Once #1307 lands and the badge rendering is verified, #1288 can be closed.

  5. Aryan-Verma-999 commented on Aug 3, 2026

    @Aryan-Verma-999
    Collaborator

    My PR #1324 touches this area, but it handles it differently from #1307,

    Ive entirely removed the deprecated global lookup path entirely:

    • removed getUsersInRole() / getUserRoles()
    • removed memberStore.admins
    • removed the MessageHeader special-case Admin badge check

    This avoids the 403s regular users hit on RC 8.x when EmbeddedChat calls role APIs such as roles.getUsersInRole.
    Room-scoped roles are still handled through getChannelRoles() (channels.roles / groups.roles) and rendered from memberRoles in MessageHeader, so channel-level owner, moderator, etc. badges remain supported.

  6. Aryan-Verma-999 commented on Aug 3, 2026

    @Aryan-Verma-999
    Collaborator

    I checked #1307 as well. It only updates getUserRoles() to fetch admin, moderator, and owner via roles.getUsersInRole, but the React side still stores the merged result in memberStore.admins and MessageHeader still renders that list with the hardcoded Admin badge.

    So as-is, #1307 would likely label moderators/owners as Admin, and it also keeps the global roles.getUsersInRole calls that can produce 403s for regular users on RC 8.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions