Add endpoint to upload avatars
This commit is contained in:
parent
ed16ee8860
commit
ef3f4a20f2
@ -127,3 +127,16 @@ async def delete_client(request: web.Request) -> web.Response:
|
|||||||
await client.stop()
|
await client.stop()
|
||||||
client.delete()
|
client.delete()
|
||||||
return resp.deleted
|
return resp.deleted
|
||||||
|
|
||||||
|
|
||||||
|
@routes.post("/client/{id}/avatar")
|
||||||
|
async def upload_avatar(request: web.Request) -> web.Response:
|
||||||
|
user_id = request.match_info.get("id", None)
|
||||||
|
client = Client.get(user_id, None)
|
||||||
|
if not client:
|
||||||
|
return resp.client_not_found
|
||||||
|
content = await request.read()
|
||||||
|
return web.json_response({
|
||||||
|
"content_uri": await client.client.upload_media(
|
||||||
|
content, request.headers.get("Content-Type", None)),
|
||||||
|
})
|
||||||
|
@ -93,6 +93,13 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/zip:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
example: The plugin maubot archive (.mbp)
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Plugin uploaded and replaced current version successfully
|
description: Plugin uploaded and replaced current version successfully
|
||||||
@ -111,14 +118,7 @@ paths:
|
|||||||
401:
|
401:
|
||||||
$ref: '#/components/responses/Unauthorized'
|
$ref: '#/components/responses/Unauthorized'
|
||||||
409:
|
409:
|
||||||
description: Plugin
|
description: Plugin already exists and allow_override was not specified.
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/zip:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
example: The plugin maubot archive (.mbp)
|
|
||||||
'/plugin/{id}':
|
'/plugin/{id}':
|
||||||
parameters:
|
parameters:
|
||||||
- name: id
|
- name: id
|
||||||
@ -169,6 +169,13 @@ paths:
|
|||||||
doesn't match the ID in the path. If the plugin already
|
doesn't match the ID in the path. If the plugin already
|
||||||
exists, enabled instances will be restarted.
|
exists, enabled instances will be restarted.
|
||||||
tags: [Plugins]
|
tags: [Plugins]
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/zip:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
example: The plugin maubot archive (.mbp)
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Plugin uploaded and replaced current version successfully
|
description: Plugin uploaded and replaced current version successfully
|
||||||
@ -186,13 +193,6 @@ paths:
|
|||||||
$ref: '#/components/responses/BadRequest'
|
$ref: '#/components/responses/BadRequest'
|
||||||
401:
|
401:
|
||||||
$ref: '#/components/responses/Unauthorized'
|
$ref: '#/components/responses/Unauthorized'
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/zip:
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
example: The plugin maubot archive (.mbp)
|
|
||||||
/plugin/{id}/reload:
|
/plugin/{id}/reload:
|
||||||
parameters:
|
parameters:
|
||||||
- name: id
|
- name: id
|
||||||
@ -399,6 +399,45 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/Error'
|
$ref: '#/components/schemas/Error'
|
||||||
|
'/client/{id}/avatar':
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
description: The Matrix user ID of the client to get
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
post:
|
||||||
|
operationId: upload_avatar
|
||||||
|
summary: Upload a profile picture for a bot
|
||||||
|
tags: [Clients]
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
image/png:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
example: The avatar to upload
|
||||||
|
image/jpeg:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
example: The avatar to upload
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: The avatar was uploaded successfully
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
content_uri:
|
||||||
|
type: string
|
||||||
|
description: The MXC URI of the uploaded avatar
|
||||||
|
400:
|
||||||
|
$ref: '#/components/responses/BadRequest'
|
||||||
|
401:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
|
||||||
components:
|
components:
|
||||||
responses:
|
responses:
|
||||||
|
Loading…
Reference in New Issue
Block a user