RocketChat / EmbeddedChat

An easy to use full-stack component (ReactJS) embedding Rocket.Chat into your webapp
https://www.npmjs.com/package/@embeddedchat/react
107 stars 214 forks source link

Fix: read only channels to work the same for all users #598

Closed devanshkansagra closed 5 days ago

devanshkansagra commented 1 week ago

Brief Title

Fixed: The read-only is also set for admins which should not be the case

Acceptance Criteria fulfillment

Fixes #541

Code that fixed

(in ChatHeader.js => getChannelInfo() function)

      const userRes = await RCInstance.getAuth();
      const isAdmin = userRes.currentUser.me.roles.includes('admin');
      if (res.success) {
        setChannelInfo(res.room);
        if (res.room.t === 'p') setIsChannelPrivate(true);
        if (res.room.ro && !isAdmin) {
          setIsChannelReadOnly(true);
          setMessageAllowed();
        }

Video/Screenshots

Screencast from 2024-06-26 12-08-54.webm

Spiral-Memory commented 1 week ago

Hey, I think you need not to do these changes. In the following code:

const canSendMsg =
          channelLevelRoles.length > 0 &&
          postMsgRoles.some((role) => allRoles.includes(role));

Just remove channelLevelRoles.length > 0 &&, and everything will start working properly."

devanshkansagra commented 1 week ago

image

Spiral-Memory commented 1 week ago

Yep, now check if things are working fine !

Remove all your codes before testing

Spiral-Memory commented 1 week ago

LGTM !

devanshkansagra commented 1 week ago

image