mirror of https://github.com/zulip/zulip.git
events: Pass can_invite_others_to_realm to client using page_params.
This commit adds backend code for passing can_invite_others_to_realm field to clients using the fetch_initial_state_data in the page_params object. Though this field is not used by webapp as of now, but will be used to fix a bug of incorreclty showing the invite users option in settings overlay in the next commit.
This commit is contained in:
parent
554ce5bf0d
commit
86f7b6af60
|
@ -10,6 +10,11 @@ below features are supported.
|
||||||
|
|
||||||
## Changes in Zulip 4.0
|
## Changes in Zulip 4.0
|
||||||
|
|
||||||
|
**Feature level 51**
|
||||||
|
|
||||||
|
* [`POST /register`](/api/register-queue): Added a new boolean field
|
||||||
|
`can_invite_others_to_realm`.
|
||||||
|
|
||||||
**Feature level 50**
|
**Feature level 50**
|
||||||
|
|
||||||
* [`POST /register`](/api/register-queue): Replaced `invite_by_admins_only`
|
* [`POST /register`](/api/register-queue): Replaced `invite_by_admins_only`
|
||||||
|
|
|
@ -30,7 +30,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
|
||||||
#
|
#
|
||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in templates/zerver/api/changelog.md.
|
# new level means in templates/zerver/api/changelog.md.
|
||||||
API_FEATURE_LEVEL = 50
|
API_FEATURE_LEVEL = 51
|
||||||
|
|
||||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
# 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
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|
|
@ -315,6 +315,7 @@ def fetch_initial_state_data(
|
||||||
|
|
||||||
state["can_create_streams"] = settings_user.can_create_streams()
|
state["can_create_streams"] = settings_user.can_create_streams()
|
||||||
state["can_subscribe_other_users"] = settings_user.can_subscribe_other_users()
|
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
|
state["is_admin"] = settings_user.is_realm_admin
|
||||||
state["is_owner"] = settings_user.is_realm_owner
|
state["is_owner"] = settings_user.is_realm_owner
|
||||||
state["is_guest"] = settings_user.is_guest
|
state["is_guest"] = settings_user.is_guest
|
||||||
|
@ -593,6 +594,7 @@ def apply_event(
|
||||||
# Recompute properties based on is_admin/is_guest
|
# Recompute properties based on is_admin/is_guest
|
||||||
state["can_create_streams"] = user_profile.can_create_streams()
|
state["can_create_streams"] = user_profile.can_create_streams()
|
||||||
state["can_subscribe_other_users"] = user_profile.can_subscribe_other_users()
|
state["can_subscribe_other_users"] = user_profile.can_subscribe_other_users()
|
||||||
|
state["can_invite_others_to_realm"] = user_profile.can_invite_others_to_realm()
|
||||||
|
|
||||||
# TODO: Probably rather than writing the perfect
|
# TODO: Probably rather than writing the perfect
|
||||||
# live-update code for the case of racing with the
|
# live-update code for the case of racing with the
|
||||||
|
@ -751,6 +753,7 @@ def apply_event(
|
||||||
policy_permission_dict = {
|
policy_permission_dict = {
|
||||||
"create_stream_policy": "can_create_streams",
|
"create_stream_policy": "can_create_streams",
|
||||||
"invite_to_stream_policy": "can_subscribe_other_users",
|
"invite_to_stream_policy": "can_subscribe_other_users",
|
||||||
|
"invite_to_realm_policy": "can_invite_others_to_realm",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tricky interaction: Whether we can create streams and can subscribe other users
|
# Tricky interaction: Whether we can create streams and can subscribe other users
|
||||||
|
|
|
@ -8366,6 +8366,15 @@ paths:
|
||||||
|
|
||||||
Whether the current user is allowed to subscribe other users to streams with
|
Whether the current user is allowed to subscribe other users to streams with
|
||||||
the organization's [streams policy](/help/configure-who-can-invite-to-streams).
|
the organization's [streams policy](/help/configure-who-can-invite-to-streams).
|
||||||
|
can_invite_others_to_realm:
|
||||||
|
type: boolean
|
||||||
|
description: |
|
||||||
|
Present if `realm_user` is present in `fetch_event_types`.
|
||||||
|
|
||||||
|
Whether the current user [is allowed to invite others]
|
||||||
|
(/help/invite-new-users#change-who-can-send-invitations) to the organization.
|
||||||
|
|
||||||
|
**Changes**: New in Zulip 4.0 (feature level 51).
|
||||||
is_admin:
|
is_admin:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -50,6 +50,7 @@ class HomeTest(ZulipTestCase):
|
||||||
"avatar_url_medium",
|
"avatar_url_medium",
|
||||||
"bot_types",
|
"bot_types",
|
||||||
"can_create_streams",
|
"can_create_streams",
|
||||||
|
"can_invite_others_to_realm",
|
||||||
"can_subscribe_other_users",
|
"can_subscribe_other_users",
|
||||||
"color_scheme",
|
"color_scheme",
|
||||||
"cross_realm_bots",
|
"cross_realm_bots",
|
||||||
|
|
Loading…
Reference in New Issue