Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

api: Fix permissions querying channel/group membership of bots.

Alex Vandiverde1420af49ea
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index a96bfe15d2e..6e48d032f7c 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,15 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 12.0
+**Feature level 458**
+
+* [`GET users/{user_id}/channels`](/api/get-user-channels): Fixed
+ missing support for querying subscriptions of bot users.
+* [`GET /users/{user_id}/subscriptions/{stream_id}`](/api/get-subscription-status):
+ Fixed missing support for querying subscriptions of bot users.
+* [`GET /user_groups/{user_group_id}/members/{user_id}`](/api/get-is-user-group-member):
+ Fixed missing support for querying group membership of bot users.
+
**Feature level 457**
[`GET /events`](/api/get-events): `delete_message` events are now
diff --git a/version.py b/version.py
index 9d96c198a30..b2eae803782 100644
--- a/version.py
+++ b/version.py
@@ -35,7 +35,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# new level means in api_docs/changelog.md, as well as "**Changes**"
# entries in the endpoint's documentation in `zulip.yaml`.
-API_FEATURE_LEVEL = 457
+API_FEATURE_LEVEL = 458
# 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/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index bb5117fe4d8..215ff60460e 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -13417,7 +13417,10 @@ paths:
description: |
Check whether a user is subscribed to a channel.
- **Changes**: New in Zulip 3.0 (feature level 12).
+ **Changes**: Prior to Zulip 12.0 (feature level 458), this endpoint
+ did not support querying subscriptions of bot users.
+
+ New in Zulip 3.0 (feature level 12).
parameters:
- $ref: "#/components/parameters/UserId"
- $ref: "#/components/parameters/ChannelIdInPath"
@@ -13456,7 +13459,10 @@ paths:
the target user is subscribed to, since organization administrators
implicitly have metadata access to all channels.
- **Changes**: New in Zulip 12.0 (feature level 440).
+ **Changes**: Prior to Zulip 12.0 (feature level 458), target users that
+ were bots resulted in a permissions error.
+
+ New in Zulip 12.0 (feature level 440).
parameters:
- $ref: "#/components/parameters/UserId"
responses:
@@ -24618,7 +24624,10 @@ paths:
description: |
Check whether a user is member of user group.
- **Changes**: Prior to Zulip 10.0 (feature level 303),
+ **Changes**: Prior to Zulip 12.0 (feature level 458), this endpoint
+ did not support querying group membership of bot users.
+
+ Prior to Zulip 10.0 (feature level 303),
this would return true when passed a deactivated user
who was a member of the user group before being deactivated.
diff --git a/zerver/views/user_groups.py b/zerver/views/user_groups.py
index 2728cab0e45..3de11eb5e6b 100644
--- a/zerver/views/user_groups.py
+++ b/zerver/views/user_groups.py
@@ -546,7 +546,7 @@ def get_is_user_group_member(
user_id: PathOnly[Json[int]],
) -> HttpResponse:
user_group = access_user_group_to_read_membership(user_group_id, user_profile.realm)
- target_user = access_user_by_id(user_profile, user_id, for_admin=False)
+ target_user = access_user_by_id(user_profile, user_id, allow_bots=True, for_admin=False)
return json_success(
request,
diff --git a/zerver/views/users.py b/zerver/views/users.py
index d832d733cf8..5620b1ab202 100644
--- a/zerver/views/users.py
+++ b/zerver/views/users.py
@@ -941,7 +941,7 @@ def get_subscription_backend(
stream_id: PathOnly[Json[int]],
user_id: PathOnly[Json[int]],
) -> HttpResponse:
- target_user = access_user_by_id(user_profile, user_id, for_admin=False)
+ target_user = access_user_by_id(user_profile, user_id, allow_bots=True, for_admin=False)
(_stream, _sub) = access_stream_by_id(user_profile, stream_id, require_content_access=False)
subscription_status = {"is_subscribed": subscribed_to_stream(target_user, stream_id)}
@@ -956,7 +956,7 @@ def get_subscribed_channels_backend(
*,
user_id: PathOnly[Json[int]],
) -> HttpResponse:
- target_user = access_user_by_id(user_profile, user_id, for_admin=False)
+ target_user = access_user_by_id(user_profile, user_id, allow_bots=True, for_admin=False)
streams = get_metadata_access_streams(
user_profile,
list(get_user_subscribed_streams(target_user)),