1
0

More avatar providers (#622)

Don't fail if the last avatar file does not exist when deleting it

Fix lint

Remove old global avatar setting and update docs

Generate docs

Invalidate the avatar cache when uploading a new one

Add debug logs

Add caching for upload avatars

Add cache locks

Fix encoding

Resize the uploaded image to a max of 1024 pixels

Remove the old uploaded avatar if one already exists

Add mimetype check for images

Set avatar provider to upload when uploading an avatar

Add upload avatar provider

Make font size smaller to let the initials still look good in smaller sizes

Add debug log

Add cache and resizing of initials avatars

Make font size depend on avatar size

Add drawing initials avatar

Add initials provider

Make the initials avatar provider the default

Add routes

Add user avatar settings handler methods

Add user avatar provider field

Co-authored-by: kolaente <k@knt.li>
Reviewed-on: https://kolaente.dev/vikunja/api/pulls/622
This commit is contained in:
konrad
2020-08-02 17:16:58 +00:00
parent c9117dd037
commit dfb7730b63
24 changed files with 1287 additions and 33 deletions

View File

@ -923,6 +923,12 @@ var doc = `{
"$ref": "#/definitions/models.Message"
}
},
"400": {
"description": "File is no image.",
"schema": {
"$ref": "#/definitions/models.Message"
}
},
"403": {
"description": "File too large.",
"schema": {
@ -1517,6 +1523,70 @@ var doc = `{
}
}
},
"/lists/{listID}/duplicate": {
"put": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Copies the list, tasks, files, kanban data, assignees, comments, attachments, lables, relations, backgrounds, user/team rights and link shares from one list to a new namespace. The user needs read access in the list and write access in the namespace of the new list.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"list"
],
"summary": "Duplicate an existing list",
"parameters": [
{
"type": "integer",
"description": "The list ID to duplicate",
"name": "listID",
"in": "path",
"required": true
},
{
"description": "The target namespace which should hold the copied list.",
"name": "list",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.ListDuplicate"
}
}
],
"responses": {
"200": {
"description": "The created list.",
"schema": {
"$ref": "#/definitions/models.ListDuplicate"
}
},
"400": {
"description": "Invalid list duplicate object provided.",
"schema": {
"$ref": "#/definitions/web.HTTPError"
}
},
"403": {
"description": "The user does not have access to the list or namespace",
"schema": {
"$ref": "#/definitions/web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/lists/{listID}/tasks": {
"get": {
"security": [
@ -5476,6 +5546,150 @@ var doc = `{
}
}
},
"/user/settings/avatar": {
"get": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Returns the current user's avatar setting.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Return user avatar setting",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.UserAvatarProvider"
}
},
"400": {
"description": "Something's invalid.",
"schema": {
"$ref": "#/definitions/web.HTTPError"
}
},
"500": {
"description": "Internal server error.",
"schema": {
"$ref": "#/definitions/models.Message"
}
}
}
},
"post": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Changes the user avatar. Valid types are gravatar (uses the user email), upload, initials, default.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Set the user's avatar",
"parameters": [
{
"description": "The user's avatar setting",
"name": "avatar",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.UserAvatarProvider"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.UserAvatarProvider"
}
},
"400": {
"description": "Something's invalid.",
"schema": {
"$ref": "#/definitions/web.HTTPError"
}
},
"500": {
"description": "Internal server error.",
"schema": {
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/user/settings/avatar/upload": {
"put": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Upload a user avatar. This will also set the user's avatar provider to \"upload\"",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Upload a user avatar",
"parameters": [
{
"type": "string",
"description": "The avatar as single file.",
"name": "avatar",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "The avatar was set successfully.",
"schema": {
"$ref": "#/definitions/models.Message"
}
},
"400": {
"description": "File is no image.",
"schema": {
"$ref": "#/definitions/models.Message"
}
},
"403": {
"description": "File too large.",
"schema": {
"$ref": "#/definitions/models.Message"
}
},
"500": {
"description": "Internal error",
"schema": {
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/user/settings/email": {
"post": {
"security": [
@ -6297,6 +6511,20 @@ var doc = `{
}
}
},
"models.ListDuplicate": {
"type": "object",
"properties": {
"list": {
"description": "The copied list",
"type": "object",
"$ref": "#/definitions/models.List"
},
"namespace_id": {
"description": "The target namespace ID",
"type": "integer"
}
}
},
"models.ListUser": {
"type": "object",
"properties": {
@ -7037,6 +7265,14 @@ var doc = `{
}
}
},
"v1.UserAvatarProvider": {
"type": "object",
"properties": {
"avatar_provider": {
"type": "string"
}
}
},
"v1.UserPassword": {
"type": "object",
"properties": {
@ -7048,6 +7284,17 @@ var doc = `{
}
}
},
"v1.legalInfo": {
"type": "object",
"properties": {
"imprint_url": {
"type": "string"
},
"privacy_policy_url": {
"type": "string"
}
}
},
"v1.vikunjaInfos": {
"type": "object",
"properties": {
@ -7066,6 +7313,10 @@ var doc = `{
"frontend_url": {
"type": "string"
},
"legal": {
"type": "object",
"$ref": "#/definitions/v1.legalInfo"
},
"link_sharing_enabled": {
"type": "boolean"
},