mirror of https://github.com/zulip/zulip.git
events: Add 'is_moderator' field to the page_params object sent to clients.
This commit is contained in:
parent
dc771f3a14
commit
bd78b1ff90
|
@ -12,6 +12,9 @@ below features are supported.
|
||||||
|
|
||||||
**Feature level 60**
|
**Feature level 60**
|
||||||
|
|
||||||
|
* [`POST /register`](/api/register-queue): Added a new boolean field
|
||||||
|
`is_moderator`, similar to the existing `is_admin`, `is_owner` and
|
||||||
|
`is_guest` fields, to the response.
|
||||||
* [`PATCH /users/{user_id}`](/api/update-user): Added support for
|
* [`PATCH /users/{user_id}`](/api/update-user): Added support for
|
||||||
changing a user's organization-level role to moderator.
|
changing a user's organization-level role to moderator.
|
||||||
* API endpoints that return `role` values can now return `300`, the
|
* API endpoints that return `role` values can now return `300`, the
|
||||||
|
|
|
@ -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 = 59
|
API_FEATURE_LEVEL = 60
|
||||||
|
|
||||||
# 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
|
||||||
|
|
|
@ -337,6 +337,7 @@ def fetch_initial_state_data(
|
||||||
state["can_invite_others_to_realm"] = settings_user.can_invite_others_to_realm()
|
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_moderator"] = settings_user.is_moderator
|
||||||
state["is_guest"] = settings_user.is_guest
|
state["is_guest"] = settings_user.is_guest
|
||||||
state["user_id"] = settings_user.id
|
state["user_id"] = settings_user.id
|
||||||
state["enter_sends"] = settings_user.enter_sends
|
state["enter_sends"] = settings_user.enter_sends
|
||||||
|
@ -609,6 +610,7 @@ def apply_event(
|
||||||
if "role" in person:
|
if "role" in person:
|
||||||
state["is_admin"] = is_administrator_role(person["role"])
|
state["is_admin"] = is_administrator_role(person["role"])
|
||||||
state["is_owner"] = person["role"] == UserProfile.ROLE_REALM_OWNER
|
state["is_owner"] = person["role"] == UserProfile.ROLE_REALM_OWNER
|
||||||
|
state["is_moderator"] = person["role"] == UserProfile.ROLE_MODERATOR
|
||||||
state["is_guest"] = person["role"] == UserProfile.ROLE_GUEST
|
state["is_guest"] = person["role"] == UserProfile.ROLE_GUEST
|
||||||
# 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()
|
||||||
|
|
|
@ -8935,6 +8935,14 @@ paths:
|
||||||
Present if `realm_user` is present in `fetch_event_types`.
|
Present if `realm_user` is present in `fetch_event_types`.
|
||||||
|
|
||||||
Whether the current user is an [organization owner](/help/roles-and-permissions).
|
Whether the current user is an [organization owner](/help/roles-and-permissions).
|
||||||
|
is_moderator:
|
||||||
|
type: boolean
|
||||||
|
description: |
|
||||||
|
Present if `realm_user` is present in `fetch_event_types`.
|
||||||
|
|
||||||
|
Whether the current user is an [organization moderator](/help/roles-and-permissions).
|
||||||
|
|
||||||
|
**Changes**: New in Zulip 4.0 (feature level 60).
|
||||||
is_guest:
|
is_guest:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -1303,6 +1303,22 @@ class NormalActionsTest(BaseAction):
|
||||||
check_realm_user_update("events[0]", events[0], "role")
|
check_realm_user_update("events[0]", events[0], "role")
|
||||||
self.assertEqual(events[0]["person"]["role"], role)
|
self.assertEqual(events[0]["person"]["role"], role)
|
||||||
|
|
||||||
|
def test_change_is_moderator(self) -> None:
|
||||||
|
reset_emails_in_zulip_realm()
|
||||||
|
|
||||||
|
# Important: We need to refresh from the database here so that
|
||||||
|
# we don't have a stale UserProfile object with an old value
|
||||||
|
# for email being passed into this next function.
|
||||||
|
self.user_profile.refresh_from_db()
|
||||||
|
|
||||||
|
do_change_user_role(self.user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
|
||||||
|
for role in [UserProfile.ROLE_MODERATOR, UserProfile.ROLE_MEMBER]:
|
||||||
|
events = self.verify_action(
|
||||||
|
lambda: do_change_user_role(self.user_profile, role, acting_user=None)
|
||||||
|
)
|
||||||
|
check_realm_user_update("events[0]", events[0], "role")
|
||||||
|
self.assertEqual(events[0]["person"]["role"], role)
|
||||||
|
|
||||||
def test_change_is_guest(self) -> None:
|
def test_change_is_guest(self) -> None:
|
||||||
reset_emails_in_zulip_realm()
|
reset_emails_in_zulip_realm()
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ class HomeTest(ZulipTestCase):
|
||||||
"insecure_desktop_app",
|
"insecure_desktop_app",
|
||||||
"is_admin",
|
"is_admin",
|
||||||
"is_guest",
|
"is_guest",
|
||||||
|
"is_moderator",
|
||||||
"is_owner",
|
"is_owner",
|
||||||
"is_web_public_visitor",
|
"is_web_public_visitor",
|
||||||
"jitsi_server_url",
|
"jitsi_server_url",
|
||||||
|
|
Loading…
Reference in New Issue