Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Grant authorization to guest users to subscribe.
Clara Dantas0994b029d631
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex 5fa5d12e61e..c28b7bb048e 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -408,6 +408,10 @@ def filter_stream_authorization(user_profile: UserProfile,if stream.id in streams_subscribed:continue+ # Web public streams are accessible even to guests+ if stream.is_web_public:+ continue+# Members and administrators are authorized for public streamsif not stream.invite_only and not user_profile.is_guest:continuediff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex 4bfd8e1ec13..5f40cd1f360 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -2871,6 +2871,21 @@ class SubscriptionAPITest(ZulipTestCase):self.assertEqual(filter_stream_authorization(guest_user, [stream]),([], [stream]))+ web_public_stream = self.make_stream('web_public_stream', is_web_public=True)+ public_stream = self.make_stream('public_stream', invite_only=False)+ private_stream = self.make_stream('private_stream2', invite_only=True)+ # This test should be added as soon as the subscription endpoint allows+ # guest users to subscribe to web public streams. Although they are already+ # authorized, the decorator in "add_subscriptions_backend" still needs to be+ # deleted.+ #+ # result = self.common_subscribe_to_streams(guest_user, ['web_public_stream'],+ # is_web_public=True, allow_fail=True)+ # self.assert_json_success(result)+ streams_to_sub = [web_public_stream, public_stream, private_stream]+ self.assertEqual(filter_stream_authorization(guest_user, streams_to_sub),+ ([web_public_stream], [public_stream, private_stream]))+def test_users_getting_add_peer_event(self) -> None:"""Check users getting add_peer_event is correct