From 18a8125dac0f8c50b62b6bf82688254511ee2dbe Mon Sep 17 00:00:00 2001 From: Aditya Kumar Kasaudhan Date: Sat, 26 Oct 2024 20:25:31 +0530 Subject: [PATCH] user_groups: Include group_id in success response on group creation. Previously, the `group_id` was not returned in the success response of the user group creation API. This commit updates the API to return a success response containing the unique ID of the user group with the key `group_id`. This enhancement allows clients to easily reference the newly created user group. Fixes: #29686 --- api_docs/changelog.md | 7 +++++++ version.py | 2 +- zerver/openapi/zulip.yaml | 25 ++++++++++++++++++++++++- zerver/views/user_groups.py | 3 +-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 30a0dbeae5..a306d3a361 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with. ## Changes in Zulip 10.0 +**Feature level 317** + +* [`POST /user_groups/create`](/api/create-user-group): + Added `group_id` to the success response of the user group creation + endpoint, enabling clients to easily access the unique identifier + of the newly created user group. + **Feature level 316** * `PATCH /realm`, [`GET /events`](/api/get-events), diff --git a/version.py b/version.py index a1d505fa9e..d5826b3aaf 100644 --- a/version.py +++ b/version.py @@ -34,7 +34,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 = 316 # Last bumped for `can_move_messages_between_topics_group` +API_FEATURE_LEVEL = 317 # Last bumped for inclusion of `group_id` in user group creation response. # 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 bc313f4399..1ecc82690f 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -20457,7 +20457,30 @@ paths: contentType: application/json responses: "200": - $ref: "#/components/responses/SimpleSuccess" + description: | + A success response containing the unique ID of the user group. + This field provides a straightforward way to reference the + newly created user group. + + **Changes**: New in Zulip 10.0 (feature level 317). + content: + application/json: + schema: + allOf: + - $ref: "#/components/schemas/JsonSuccessBase" + - required: + - group_id + additionalProperties: false + properties: + result: {} + msg: {} + ignored_parameters_unsupported: {} + group_id: + type: integer + description: | + The unique ID of the created user group. + example: {"msg": "", "result": "success", "group_id": 123} + "400": description: Bad request. content: diff --git a/zerver/views/user_groups.py b/zerver/views/user_groups.py index 04bae18a12..ae2473ec42 100644 --- a/zerver/views/user_groups.py +++ b/zerver/views/user_groups.py @@ -101,8 +101,7 @@ def add_user_group( add_subgroups_to_user_group( context.supergroup, context.direct_subgroups, acting_user=user_profile ) - - return json_success(request) + return json_success(request, data={"group_id": user_group.id}) @require_member_or_admin