diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index c04818bd59..5a406903c6 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -16,6 +16,8 @@ below features are supported. * [`POST /register`](/api/register-queue): Added `create_web_public_stream_policy` policy for which users can create web public streams. * [`PATCH /realm`]: Added support for updating `create_web_public_stream_policy`. +* [`POST /register`](/api/register-queue): Added `can_create_web_public_streams` boolean + field to the response. **Feature level 102** diff --git a/version.py b/version.py index aece742257..ac6b519911 100644 --- a/version.py +++ b/version.py @@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3" # Changes should be accompanied by documentation explaining what the # new level means in templates/zerver/api/changelog.md, as well as # "**Changes**" entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 102 +API_FEATURE_LEVEL = 103 # Bump the minor PROVISION_VERSION to indicate that folks should provision # only when going from an old version of the code to a newer version. Bump diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 004ee3a38a..745c78863d 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -417,8 +417,11 @@ def fetch_initial_state_data( # 102); we can remove this once we no longer need to support # legacy mobile app versions that read the old property. state["can_create_streams"] = ( - settings_user.can_create_private_streams() or settings_user.can_create_public_streams() + settings_user.can_create_private_streams() + or settings_user.can_create_public_streams() + or settings_user.can_create_web_public_streams() ) + state["can_create_web_public_streams"] = settings_user.can_create_web_public_streams() state["can_subscribe_other_users"] = settings_user.can_subscribe_other_users() state["can_invite_others_to_realm"] = settings_user.can_invite_others_to_realm() state["is_admin"] = settings_user.is_realm_admin @@ -752,8 +755,13 @@ def apply_event( # Recompute properties based on is_admin/is_guest state["can_create_private_streams"] = user_profile.can_create_private_streams() state["can_create_public_streams"] = user_profile.can_create_public_streams() + state[ + "can_create_web_public_streams" + ] = user_profile.can_create_web_public_streams() state["can_create_streams"] = ( - state["can_create_private_streams"] or state["can_create_public_streams"] + state["can_create_private_streams"] + or state["can_create_public_streams"] + or state["can_create_web_public_streams"] ) state["can_subscribe_other_users"] = user_profile.can_subscribe_other_users() state["can_invite_others_to_realm"] = user_profile.can_invite_others_to_realm() @@ -942,6 +950,7 @@ def apply_event( policy_permission_dict = { "create_public_stream_policy": "can_create_public_streams", "create_private_stream_policy": "can_create_private_streams", + "create_web_public_stream_policy": "can_create_web_public_streams", "invite_to_stream_policy": "can_subscribe_other_users", "invite_to_realm_policy": "can_invite_others_to_realm", } @@ -962,7 +971,9 @@ def apply_event( # Finally, we need to recompute this value from its inputs. state["can_create_streams"] = ( - state["can_create_private_streams"] or state["can_create_public_streams"] + state["can_create_private_streams"] + or state["can_create_public_streams"] + or state["can_create_web_public_streams"] ) elif event["op"] == "update_dict": for key, value in event["data"].items(): diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 4ba274ad74..e55ed2a89e 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -11462,6 +11462,18 @@ paths: **Changes**: New in Zulip 5.0 (feature level 102). In older versions, the deprecated `can_create_streams` property should be used to determine whether the user can create private streams. + can_create_web_public_streams: + type: boolean + description: | + Present if `realm_user` is present in `fetch_event_types`. + + Whether the current user is allowed to create public streams with + the organization's [stream creation policy](/help/configure-who-can-create-streams). + + Note that this will be false if the Zulip server does not have the + `WEB_PUBLIC_STREAMS_ENABLED` setting enabled. + + **Changes**: New in Zulip 5.0 (feature level 103). can_subscribe_other_users: type: boolean description: | diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index f351ed6f7f..3896dba8e3 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -53,6 +53,7 @@ class HomeTest(ZulipTestCase): "can_create_private_streams", "can_create_public_streams", "can_create_streams", + "can_create_web_public_streams", "can_invite_others_to_realm", "can_subscribe_other_users", "corporate_enabled",