RocketChat / EmbeddedChat

An easy to use full-stack component (ReactJS) embedding Rocket.Chat into your webapp
https://rocketchat.github.io/EmbeddedChat/docs
125 stars 251 forks source link

[BUG] Unable to access private channel information and older chats #423

Closed Spiral-Memory closed 9 months ago

Spiral-Memory commented 10 months ago

Description:

The application currently cannot fetch the information of a private channel properly. The older messages are not displayed in the private channel, even for authorized users, although they can send messages. Users who are not members of the private channel can still log in, but they get logged out when trying to send a message without receiving any information on why they were logged out, resulting in an unpleasant experience.

Steps to reproduce:

  1. Set up the Rocket.Chat Server.
  2. Adjust the channel permissions to private.
  3. Access the embedded chat, log in, and compare the observed behavior with the expected.

Expected behavior:

When the channel is private, only permit users who have joined or have permission to log in and communicate. Also, they must be able to access the channel information and view older messages in the chat. Additionally, log out any unauthorised user attempting to log in with information that suggests the channel doesn't exist or they are not allowed to join.

Actual behavior:

For private channels, users with permission also can't see older messages, although they can send messages. Users who are not members of the private channel can still log in, but they get logged out when trying to send a message without receiving any information on why they were logged out, resulting in an unpleasant experience.

https://github.com/RocketChat/EmbeddedChat/assets/78961432/27441077-aea0-4070-ba80-28167e6f1ec5

Spiral-Memory commented 10 months ago

Hey @abhinavkrin , I would like to work on this issue as discussed, I feel that the problem arises because the API used to fetch channel information is /api/v1/channels.info, which can't retrieve the information of private channels. To fetch information of private channels, the API /api/v1/rooms.get or /api/v1/groups.info has to be used. Also, we can use the /api/v1/groups.${query} endpoint to fetch messages and get roles for private channels(groups).The suggested approach is to use both APIs in combination to handle both kinds of channels. Let me know about the approach that you think could be taken to fix this.

Spiral-Memory commented 10 months ago

I have submitted the PR following the approach I proposed. Please let me know if any changes are necessary.

Note: This PR may lead to merge conflicts with #419 and #421 due to alterations in similar locations. Additionally, PR #427 is essential to maintain synchronization on refresh. These four PRs are closely connected and collectively address the comprehensive issue #417 you advised me to break down into separate tasks. As you begin the review, I will resolve any merge conflicts with each merge. Thank you!