mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 22:19:48 +00:00
streams: Split setting for stream creation policy.
Users wanted a feature where they could specify which users can create public streams and which users can create private streams. This splits stream creation code into two parts, public and private stream creation. Fixes #17009.
This commit is contained in:
@@ -149,10 +149,11 @@ def create_streams_if_needed(
|
||||
added_streams: List[Stream] = []
|
||||
existing_streams: List[Stream] = []
|
||||
for stream_dict in stream_dicts:
|
||||
invite_only = stream_dict.get("invite_only", False)
|
||||
stream, created = create_stream_if_needed(
|
||||
realm,
|
||||
stream_dict["name"],
|
||||
invite_only=stream_dict.get("invite_only", False),
|
||||
invite_only=invite_only,
|
||||
is_web_public=stream_dict.get("is_web_public", False),
|
||||
stream_post_policy=stream_dict.get(
|
||||
"stream_post_policy", Stream.STREAM_POST_POLICY_EVERYONE
|
||||
@@ -671,10 +672,12 @@ def list_to_streams(
|
||||
created_streams: List[Stream] = []
|
||||
else:
|
||||
# autocreate=True path starts here
|
||||
if not user_profile.can_create_streams():
|
||||
# Guest users case will not be handled here as it will be
|
||||
# handled by the decorator in add_subscriptions_backend.
|
||||
raise JsonableError(_("Insufficient permission"))
|
||||
for stream_dict in missing_stream_dicts:
|
||||
invite_only = stream_dict.get("invite_only", False)
|
||||
if invite_only and not user_profile.can_create_private_streams():
|
||||
raise JsonableError(_("Insufficient permission"))
|
||||
if not invite_only and not user_profile.can_create_public_streams():
|
||||
raise JsonableError(_("Insufficient permission"))
|
||||
|
||||
if not autocreate:
|
||||
raise JsonableError(
|
||||
|
||||
Reference in New Issue
Block a user