Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Users without preview permission subscribing to public channel stream #34922

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

tiagoevanp
Copy link
Contributor

@tiagoevanp tiagoevanp commented Jan 9, 2025

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

CORE-855

Copy link
Contributor

dionisio-bot bot commented Jan 9, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Jan 9, 2025

⚠️ No Changeset found

Latest commit: af11983

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 9, 2025

PR Preview Action v1.5.0
🚀 Deployed preview to https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-34922/
on branch gh-pages at 2025-01-09 18:20 UTC

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.18%. Comparing base (4aa95b6) to head (af11983).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #34922      +/-   ##
===========================================
+ Coverage    59.13%   59.18%   +0.04%     
===========================================
  Files         2819     2819              
  Lines        67957    67762     -195     
  Branches     15138    15075      -63     
===========================================
- Hits         40188    40102      -86     
+ Misses       24935    24838      -97     
+ Partials      2834     2822      -12     
Flag Coverage Δ
unit 74.99% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

if (!hasPermission('preview-c-room') && room.t === 'c' && !subscription) {
return;
}

if (record.streamActive !== true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't if (record.streamActive !== true) { check come first?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because if stream not active we will have exactly what we are trying to avoid, load the stream.
In this case we have another check who comes first, and it's related to preview the public room with no subscriptions...

@@ -85,11 +86,31 @@ const ComposerMessage = ({ tmid, onSend, ...props }: ComposerMessageProps): Reac
useCallback(() => LegacyRoomManager.getOpenedRoomByRid(room._id)?.streamActive ?? false, [room._id]),
);

if (!publicationReady) {
if (!publicationReady && hasPreviewPublicRoomPermission) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I'm part of the room and I don't have this permission? Won't it break the loading composer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because publicationReady turns into true!
But if we proceed with the new design, the one without composer, we should be fine and remove this permission check!

Comment on lines +93 to +99
const subscribe = () => {
if (!hasPreviewPublicRoomPermission) {
// Get room subscription
LegacyRoomManager.open({ rid: room._id, typeName: room.t });
LegacyRoomManager.computation.invalidate();
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useOpenRoom already does LegacyRoomManager.open. Also, why is this fn called subscribe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but a lot of other things too. And it does not do the computation.invalidate too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants