Repository navigation
getUserRoles only fetches admins, moderator and owner badges never shown #1288
Description
Activity
@Spiral-Memory found this while going through the role-fetching code. The fix would be to call
getUsersInRoleformoderatorandowneralongsideadmin, merge the results, and store them in a structure thatMessageHeadercan check per role type to render the right badge. Happy to pick this up.@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
I think @Aryan-Verma-999 has addressed the issue in his previous PR. Can you please confirm
@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()inpackages/api/src/EmbeddedChatApi.tsto callgetUsersInRolefor["admin", "moderator", "owner"], merge and dedupe the results — which directly addresses the root cause described in #1288 (onlyadminwas being fetched).Two caveats before we mark #1288 resolved:
- PR fix: fetch admin, moderator, and owner roles for message badges #1307 is still open (not merged).
- It only changes
EmbeddedChatApi.ts. The issue also notesMessageHeader.jsonly checksadmins— 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.
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
MessageHeaderspecial-caseAdminbadge 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 throughgetChannelRoles()(channels.roles/groups.roles) and rendered frommemberRolesinMessageHeader, so channel-levelowner,moderator, etc. badges remain supported.- removed
I checked #1307 as well. It only updates
getUserRoles()to fetchadmin,moderator, andownerviaroles.getUsersInRole, but the React side still stores the merged result inmemberStore.adminsandMessageHeaderstill renders that list with the hardcodedAdminbadge.So as-is, #1307 would likely label moderators/owners as
Admin, and it also keeps the globalroles.getUsersInRolecalls that can produce 403s for regular users on RC 8.x.
getUserRoles()inEmbeddedChatApi.ts:671-682hardcodes a single call togetUsersInRole("admin"). It never fetches moderators or owners. The result feeds intomemberStore.admins, whichMessageHeader.js:140checks to show the "Admin" badge — but there's no equivalent for moderator or owner roles, so those badges never render.The per-room roles from
channels.roles/groups.rolesAPI do get fetched separately and shown viachannelLevelRolesinMessageHeader.js:150, so room-scoped roles work. But the global moderator/owner roles are just missing.Steps to reproduce:
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 queriesadminrolepackages/react/src/views/Message/MessageHeader.js:140— only checksadminsarray