Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Extract zephyr realm invite check.
apoorvapendse4d49fa6fbbf4
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex fc071d39a1b..53b3a0b711e 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -997,6 +997,15 @@ def check_stream_name_available(realm: Realm, name: str) -> None:pass+def check_zephyr_realm_invite_conditions(+ is_subscribing_other_users: bool, realm: Realm, invite_only: bool+) -> None:+ if is_subscribing_other_users and realm.is_zephyr_mirror_realm and not invite_only:+ raise JsonableError(+ _("You can only invite other Zephyr mirroring users to private channels.")+ )++def access_stream_by_name(user_profile: UserProfile,stream_name: str,diff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex b1f5b0455fe..97d5d65cf77 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -75,6 +75,7 @@ from zerver.lib.streams import (access_web_public_stream,channel_events_topic_name,check_stream_name_available,+ check_zephyr_realm_invite_conditions,do_get_streams,filter_stream_authorization_for_adding_subscribers,get_anonymous_group_membership_dict_for_streams,@@ -844,14 +845,8 @@ def add_subscriptions_backend(# Newly created streams are also authorized for the creatorstreams = authorized_streams + created_streams- if (- is_subscribing_other_users- and realm.is_zephyr_mirror_realm- and not all(stream.invite_only for stream in streams)- ):- raise JsonableError(- _("You can only invite other Zephyr mirroring users to private channels.")- )+ for stream in streams:+ check_zephyr_realm_invite_conditions(is_subscribing_other_users, realm, stream.invite_only)if is_subscribing_other_users:subscribers = bulk_principals_to_user_profiles(principals, user_profile)