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 docs: Document POST and DELETE /users/me/avatar.

Agnish Baurid15d6f7af312
diff --git a/api_docs/include/rest-endpoints.md b/api_docs/include/rest-endpoints.md
index c6c5730da85..7c102bba95c 100644
--- a/api_docs/include/rest-endpoints.md
+++ b/api_docs/include/rest-endpoints.md
@@ -98,6 +98,8 @@
* [Update user status](/api/update-status-for-user)
* [Update your profile data](/api/update-profile-data)
* [Remove your profile data](/api/remove-profile-data)
+* [Upload your profile picture](/api/upload-avatar)
+* [Delete your profile picture](/api/delete-avatar)
* [Set "typing" status](/api/set-typing-status)
* [Set "typing" status for message editing](/api/set-typing-status-for-message-edit)
* [Get a user's presence](/api/get-user-presence)
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 3d36e422bbb..f44e8d54e50 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -16064,7 +16064,169 @@ paths:
responses:
"200":
$ref: "#/components/responses/SuccessIgnoredParameters"
+ /users/me/avatar:
+ post:
+ operationId: upload-avatar
+ summary: Upload your profile picture
+ tags: ["users"]
+ description: |
+ Upload a new [profile picture](/help/change-your-profile-picture)
+ for the current user.
+
+ The maximum allowed file size is available in the `max_avatar_file_size_mib`
+ field in the [`POST /register`](/api/register-queue) response.
+
+ In organizations that
+ [restrict profile picture changes](/help/restrict-profile-picture-changes),
+ only administrators can use this endpoint.
+ x-parameter-description: |
+ The profile picture image file must be provided in the request's body
+ as multipart form data.
+ requestBody:
+ required: true
+ content:
+ multipart/form-data:
+ schema:
+ type: object
+ additionalProperties: false
+ properties:
+ file:
+ type: string
+ format: binary
+ example: "zerver/tests/images/img.png"
+ required:
+ - file
+ responses:
+ "200":
+ description: Success.
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: "#/components/schemas/JsonSuccessBase"
+ - additionalProperties: false
+ properties:
+ result: {}
+ msg: {}
+ avatar_url:
+ type: string
+ description: |
+ The URL of the current user's new profile picture.
+ example:
+ {
+ "avatar_url": "/user_avatars/2/c4ce28dde2d44a08b2a72cb371fe78d99cffd7c4.png",
+ "msg": "",
+ "result": "success",
+ }
+ "400":
+ description: Bad request.
+ content:
+ application/json:
+ schema:
+ oneOf:
+ - allOf:
+ - $ref: "#/components/schemas/CodedError"
+ - description: |
+ An example JSON response for when the request did not include
+ exactly one file:
+ example:
+ {
+ "code": "BAD_REQUEST",
+ "msg": "You must upload exactly one avatar.",
+ "result": "error",
+ }
+ - allOf:
+ - $ref: "#/components/schemas/CodedError"
+ - description: |
+ An example JSON response for when the uploaded file exceeds the
+ maximum allowed size:
+ example:
+ {
+ "code": "BAD_REQUEST",
+ "msg": "Uploaded file is larger than the allowed limit of 5 MiB",
+ "result": "error",
+ }
+ - allOf:
+ - $ref: "#/components/schemas/CodedError"
+ - description: |
+ An example JSON response for when the uploaded file
+ is not a supported image format:
+ example:
+ {
+ "code": "BAD_IMAGE",
+ "msg": "Invalid image format",
+ "result": "error",
+ }
+ - allOf:
+ - $ref: "#/components/schemas/CodedError"
+ - description: |
+ An example JSON response for when a non-administrator attempts
+ to change their profile picture in an organization that has
+ disabled profile picture changes:
+ example:
+ {
+ "code": "BAD_REQUEST",
+ "msg": "Avatar changes are disabled in this organization.",
+ "result": "error",
+ }
+ delete:
+ operationId: delete-avatar
+ summary: Delete your profile picture
+ tags: ["users"]
+ description: |
+ Delete the current user's uploaded [profile picture](/help/change-your-profile-picture),
+ reverting to the organization's
+ [default style for profile pictures](/help/configure-default-profile-pictures).
+
+ This endpoint is idempotent: if the current user has not uploaded a
+ custom profile picture, the request succeeds without making any
+ changes.
+ In organizations that
+ [restrict profile picture changes](/help/restrict-profile-picture-changes),
+ only administrators can use this endpoint.
+ responses:
+ "200":
+ description: Success.
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: "#/components/schemas/JsonSuccessBase"
+ - additionalProperties: false
+ properties:
+ result: {}
+ msg: {}
+ avatar_url:
+ type: string
+ description: |
+ The URL of the current user's profile picture, which
+ now uses the organization's default style for profile
+ pictures. Its format depends on whether that style is
+ the default abstract design or Gravatar.
+ example:
+ {
+ "avatar_url": "/user_avatars/2/3a7bd3e2360a3d29eea436fcfb7e44c735d117c4.png",
+ "msg": "",
+ "result": "success",
+ }
+ "400":
+ description: Bad request.
+ content:
+ application/json:
+ schema:
+ allOf:
+ - $ref: "#/components/schemas/CodedError"
+ - description: |
+ An example JSON response for when a non-administrator attempts
+ to change their profile picture in an organization that has
+ disabled profile picture changes:
+ example:
+ {
+ "code": "BAD_REQUEST",
+ "msg": "Avatar changes are disabled in this organization.",
+ "result": "error",
+ }
/users/me/subscriptions/properties:
post:
operationId: update-subscription-settings
diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.py
index 1de4bf3af9a..9e406dd420b 100644
--- a/zerver/tests/test_openapi.py
+++ b/zerver/tests/test_openapi.py
@@ -222,8 +222,6 @@ class OpenAPIArgumentsTest(ZulipTestCase):
"/default_stream_groups/create",
"/default_stream_groups/{group_id}",
"/default_stream_groups/{group_id}/streams",
- #### These personal settings endpoints have modest value to document:
- "/users/me/avatar",
#### Should be documented as part of interactive bots documentation
"/submessage",
"/zcommand",