Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
api docs: Document PATCH /users/me/subscriptions/{stream_id}.
Agnish Bauria6d4ab18c140
diff --git a/api_docs/include/rest-endpoints.md b/api_docs/include/rest-endpoints.mdindex 6fad169dd39..56d75a80829 100644--- a/api_docs/include/rest-endpoints.md+++ b/api_docs/include/rest-endpoints.md@@ -60,7 +60,8 @@* [Get subscription status](/api/get-subscription-status)* [Get channel subscribers](/api/get-subscribers)* [Get a user's subscribed channels](/api/get-user-channels)-* [Update subscription settings](/api/update-subscription-settings)+* [Update a subscription setting](/api/update-subscription-property)+* [Bulk update subscription settings](/api/update-subscription-settings)* [Get all channels](/api/get-streams)* [Get a channel by ID](/api/get-stream-by-id)* [Get channel ID](/api/get-stream-id)diff --git a/zerver/openapi/python_examples.py b/zerver/openapi/python_examples.pyindex c1d0cd4cde1..908cefa3c7a 100644--- a/zerver/openapi/python_examples.py+++ b/zerver/openapi/python_examples.py@@ -1149,6 +1149,29 @@ def update_subscription_settings(client: Client) -> None:validate_against_openapi_schema(result, "/users/me/subscriptions/properties", "POST", "200")+@openapi_test_function("/users/me/subscriptions/{stream_id}:patch")+def update_subscription_property(client: Client) -> None:+ subscriptions = client.get_subscriptions()["subscriptions"]+ assert len(subscriptions) >= 1+ stream_id = subscriptions[0]["stream_id"]++ # {code_example|start}+ # Update the user's subscription of the channel with ID `stream_id`+ # so that it's pinned to the top of the user's channel list.+ request = {+ "property": "pin_to_top",+ "value": True,+ }+ result = client.call_endpoint(+ f"users/me/subscriptions/{stream_id}",+ method="PATCH",+ request=request,+ )+ # {code_example|end}++ validate_against_openapi_schema(result, "/users/me/subscriptions/{stream_id}", "patch", "200")++@openapi_test_function("/messages/render:post")def render_message(client: Client) -> None:# {code_example|start}@@ -2149,6 +2172,7 @@ def test_streams(client: Client, nonadmin_client: Client) -> None:toggle_mute_topic(client)update_user_topic(client)update_subscription_settings(client)+ update_subscription_property(client)get_stream_topics(client, 1)delete_topic(client, 1, "test")archive_stream(client)diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 1a3bb37babb..4c23fff4dd9 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -15085,17 +15085,21 @@ paths:/users/me/subscriptions/properties:post:operationId: update-subscription-settings- summary: Update subscription settings+ summary: Bulk update subscription settingstags: ["channels"]description: |- This endpoint is used to update the user's personal settings for the- channels they are subscribed to, including muting, color, pinning, and- per-channel notification settings.+ Update the current user's personal settings for channels they are+ subscribed to. These settings include [color](/help/change-the-color-of-a-channel),+ [muting](/help/mute-a-channel), [pinning](/help/pin-a-channel)+ and [per-channel notification settings](/help/channel-notifications).- **Changes**: Prior to Zulip 5.0 (feature level 111), response- object included the `subscription_data` in the- request. The endpoint now returns the more ergonomic- [`ignored_parameters_unsupported`][ignored-parameters] array instead.+ There is a single channel alternative to this bulk endpoint:+ [`POST /users/me/subscriptions/{stream_id}`](/api/update-subscription-property).++ **Changes**: Prior to Zulip 5.0 (feature level 111), the response object+ included the `subscription_data` in the request. The endpoint now returns+ the more ergonomic [`ignored_parameters_unsupported`][ignored-parameters]+ array instead.[ignored-parameters]: /api/rest-error-handling#ignored-parametersrequestBody:@@ -15121,61 +15125,9 @@ paths:description: |The unique ID of a channel.property:- type: string- enum:- - color- - is_muted- - in_home_view- - pin_to_top- - desktop_notifications- - audible_notifications- - push_notifications- - email_notifications- - wildcard_mentions_notify- description: |- One of the channel properties described below:-- - `"color"`: The hex value of the user's display color for the channel.-- - `"is_muted"`: Whether the channel is [muted](/help/mute-a-channel).<br>- **Changes**: As of Zulip 6.0 (feature level 139), updating either- `"is_muted"` or `"in_home_view"` generates two [subscription update- events](/api/get-events#subscription-update), one for each property,- that are sent to clients. Prior to this feature level, updating either- property only generated a subscription update event for- `"in_home_view"`. <br>- Prior to Zulip 2.1.0, this feature was represented- by the more confusingly named `"in_home_view"` (with the- opposite value: `in_home_view=!is_muted`); for- backwards-compatibility, modern Zulip still accepts that property.-- - `"pin_to_top"`: Whether to pin the channel at the top of the channel list.-- - `"desktop_notifications"`: Whether to show desktop notifications- for all messages sent to the channel.-- - `"audible_notifications"`: Whether to play a sound- notification for all messages sent to the channel.-- - `"push_notifications"`: Whether to trigger a mobile push- notification for all messages sent to the channel.-- - `"email_notifications"`: Whether to trigger an email- notification for all messages sent to the channel.-- - `"wildcard_mentions_notify"`: Whether wildcard mentions trigger- notifications as though they were personal mentions in this channel.+ $ref: "#/components/schemas/SubscriptionProperty"value:- oneOf:- - type: boolean- - type: string- description: |- The new value of the property being modified.-- If the property is `"color"`, then `value` is a string- representing the hex value of the user's display- color for the channel. For all other above properties,- `value` is a boolean.+ $ref: "#/components/schemas/SubscriptionPropertyValue"required:- stream_id- property@@ -15195,6 +15147,38 @@ paths:responses:"200":$ref: "#/components/responses/SuccessIgnoredParameters"+ /users/me/subscriptions/{stream_id}:+ patch:+ operationId: update-subscription-property+ summary: Update a subscription setting+ tags: ["channels"]+ description: |+ Update the current user's personal settings for a specific channel they+ are subscribed to. These settings include [color](/help/change-the-color-of-a-channel),+ [muting](/help/mute-a-channel), [pinning](/help/pin-a-channel)+ and [per-channel notification settings](/help/channel-notifications).++ This is a single channel alternative to the bulk endpoint:+ [`POST /users/me/subscriptions/properties`](/api/update-subscription-settings).+ parameters:+ - $ref: "#/components/parameters/ChannelIdInPath"+ requestBody:+ required: true+ content:+ application/x-www-form-urlencoded:+ schema:+ type: object+ properties:+ property:+ $ref: "#/components/schemas/SubscriptionProperty"+ value:+ $ref: "#/components/schemas/SubscriptionPropertyValue"+ required:+ - property+ - value+ responses:+ "200":+ $ref: "#/components/responses/SimpleSuccess"/users/{email}:get:operationId: get-user-by-email@@ -29779,6 +29763,68 @@ components:Is `null` if channel does not belong to any folder.**Changes**: New in Zulip 11.0 (feature level 389).+ SubscriptionProperty:+ type: string+ enum:+ - color+ - is_muted+ - in_home_view+ - pin_to_top+ - desktop_notifications+ - audible_notifications+ - push_notifications+ - email_notifications+ - wildcard_mentions_notify+ description: |+ One of the channel properties described below:++ - `"color"`: The hex value of the user's display color for the channel.++ - `"is_muted"`: Whether the channel is [muted](/help/mute-a-channel).<br>+ **Changes**: As of Zulip 6.0 (feature level 139), updating either+ `"is_muted"` or `"in_home_view"` generates two [subscription update+ events](/api/get-events#subscription-update), one for each property,+ that are sent to clients. Prior to this feature level, updating either+ property only generated a subscription update event for+ `"in_home_view"`. <br>+ Prior to Zulip 2.1.0, this feature was represented+ by the more confusingly named `"in_home_view"` (with the+ opposite value: `in_home_view=!is_muted`); for+ backwards-compatibility, modern Zulip still accepts that property.++ - `"pin_to_top"`: Whether to pin the channel at the top of the channel list.++ - `"desktop_notifications"`: Whether to show desktop notifications+ for all messages sent to the channel.++ - `"audible_notifications"`: Whether to play a sound+ notification for all messages sent to the channel.++ - `"push_notifications"`: Whether to trigger a mobile push+ notification for all messages sent to the channel.++ - `"email_notifications"`: Whether to trigger an email+ notification for all messages sent to the channel.++ - `"wildcard_mentions_notify"`: Whether wildcard mentions trigger+ notifications as though they were personal mentions in this channel.+ example: "pin_to_top"+ SubscriptionPropertyValue:+ oneOf:+ - type: boolean+ description: |+ The new boolean value for the specified property.+ - type: string+ description: |+ The hex value of the user's display color for the channel.+ description: |+ The new value of the property being modified.++ If the property is `"color"`, then `value` is a string+ representing the hex value of the user's display+ color for the channel. For all other above properties,+ `value` is a boolean.+ example: "true"#################### Shared responsesdiff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.pyindex 09c97000770..27356a0f6c2 100644--- a/zerver/tests/test_openapi.py+++ b/zerver/tests/test_openapi.py@@ -217,10 +217,6 @@ class OpenAPIArgumentsTest(ZulipTestCase):#### These realm administration settings are valuable to document:# Delete a data export."/export/realm/{export_id}",- # Single-stream settings alternative to the bulk endpoint- # users/me/subscriptions/properties; probably should just be a- # section of the same page.- "/users/me/subscriptions/{stream_id}",# Default stream groups are an unfinished feature and therefore# shouldn't be added to the documentation until that's completed."/default_stream_groups/create",@@ -998,14 +994,9 @@ class OpenAPIRegexTest(ZulipTestCase):# Some of the undocumented endpoints which are very similar to# some of the documented endpoints.assert find_openapi_endpoint("/users/me/presence") is None- assert find_openapi_endpoint("/users/me/subscriptions/23") is Noneassert find_openapi_endpoint("/users/iago/subscriptions/23") is Noneassert find_openapi_endpoint("/messages/matches_narrow") is None# Making sure documented endpoints are matched correctly.- assert (- find_openapi_endpoint("/users/23/subscriptions/21")- == "/users/{user_id}/subscriptions/{stream_id}"- )assert (find_openapi_endpoint("/users/[email protected]/presence")== "/users/{user_id_or_email}/presence"