register: Add can_create_web_public_streams to register response.

This commit is contained in:
Sahil Batra
2021-10-04 22:58:33 +05:30
committed by Tim Abbott
parent 2c2c19c4d4
commit ab0d852fd5
5 changed files with 30 additions and 4 deletions

View File

@@ -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**

View File

@@ -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

View File

@@ -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():

View File

@@ -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: |

View File

@@ -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",