fix(core): Return X-NC-IsCustomAvatar for guest avatars too

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/45698/head
provokateurin 1 year ago committed by skjnldsv
parent 8bed23288b
commit c8e767878d
  1. 6
      core/Controller/AvatarController.php
  2. 6
      core/Controller/GuestAvatarController.php
  3. 102
      core/openapi.json

@ -57,9 +57,10 @@ class AvatarController extends Controller {
* @param string $userId ID of the user
* @param int $size Size of the avatar
* @param bool $guestFallback Fallback to guest avatar if not found
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar?: int}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
*
* 200: Avatar returned
* 201: Avatar returned
* 404: Avatar not found
*/
#[FrontpageRoute(verb: 'GET', url: '/avatar/{userId}/{size}/dark')]
@ -108,9 +109,10 @@ class AvatarController extends Controller {
* @param string $userId ID of the user
* @param int $size Size of the avatar
* @param bool $guestFallback Fallback to guest avatar if not found
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar?: int}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|JSONResponse<Http::STATUS_NOT_FOUND, array<empty>, array{}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
*
* 200: Avatar returned
* 201: Avatar returned
* 404: Avatar not found
*/
#[FrontpageRoute(verb: 'GET', url: '/avatar/{userId}/{size}')]

@ -39,7 +39,7 @@ class GuestAvatarController extends Controller {
* @param string $guestName The guest name, e.g. "Albert"
* @param string $size The desired avatar size, e.g. 64 for 64x64px
* @param bool|null $darkTheme Return dark avatar
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
*
* 200: Custom avatar returned
* 201: Avatar returned
@ -68,7 +68,7 @@ class GuestAvatarController extends Controller {
$resp = new FileDisplayResponse(
$avatarFile,
$avatar->isCustomAvatar() ? Http::STATUS_OK : Http::STATUS_CREATED,
['Content-Type' => $avatarFile->getMimeType()]
['Content-Type' => $avatarFile->getMimeType(), 'X-NC-IsCustomAvatar' => (int)$avatar->isCustomAvatar()]
);
} catch (\Exception $e) {
$this->logger->error('error while creating guest avatar', [
@ -92,7 +92,7 @@ class GuestAvatarController extends Controller {
*
* @param string $guestName The guest name, e.g. "Albert"
* @param string $size The desired avatar size, e.g. 64 for 64x64px
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
* @return FileDisplayResponse<Http::STATUS_OK|Http::STATUS_CREATED, array{Content-Type: string, X-NC-IsCustomAvatar: int}>|Response<Http::STATUS_INTERNAL_SERVER_ERROR, array{}>
*
* 200: Custom avatar returned
* 201: Avatar returned

@ -7318,6 +7318,19 @@
}
],
"parameters": [
{
"name": "guestFallback",
"in": "query",
"description": "Fallback to guest avatar if not found",
"schema": {
"type": "integer",
"default": 0,
"enum": [
0,
1
]
}
},
{
"name": "userId",
"in": "path",
@ -7358,6 +7371,25 @@
}
}
},
"201": {
"description": "Avatar returned",
"headers": {
"X-NC-IsCustomAvatar": {
"schema": {
"type": "integer",
"format": "int64"
}
}
},
"content": {
"*/*": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"404": {
"description": "Avatar not found",
"content": {
@ -7365,6 +7397,9 @@
"schema": {}
}
}
},
"500": {
"description": ""
}
}
}
@ -7386,6 +7421,19 @@
}
],
"parameters": [
{
"name": "guestFallback",
"in": "query",
"description": "Fallback to guest avatar if not found",
"schema": {
"type": "integer",
"default": 0,
"enum": [
0,
1
]
}
},
{
"name": "userId",
"in": "path",
@ -7426,6 +7474,25 @@
}
}
},
"201": {
"description": "Avatar returned",
"headers": {
"X-NC-IsCustomAvatar": {
"schema": {
"type": "integer",
"format": "int64"
}
}
},
"content": {
"*/*": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
},
"404": {
"description": "Avatar not found",
"content": {
@ -7433,6 +7500,9 @@
"schema": {}
}
}
},
"500": {
"description": ""
}
}
}
@ -7569,6 +7639,14 @@
"responses": {
"200": {
"description": "Custom avatar returned",
"headers": {
"X-NC-IsCustomAvatar": {
"schema": {
"type": "integer",
"format": "int64"
}
}
},
"content": {
"*/*": {
"schema": {
@ -7580,6 +7658,14 @@
},
"201": {
"description": "Avatar returned",
"headers": {
"X-NC-IsCustomAvatar": {
"schema": {
"type": "integer",
"format": "int64"
}
}
},
"content": {
"*/*": {
"schema": {
@ -7634,6 +7720,14 @@
"responses": {
"200": {
"description": "Custom avatar returned",
"headers": {
"X-NC-IsCustomAvatar": {
"schema": {
"type": "integer",
"format": "int64"
}
}
},
"content": {
"*/*": {
"schema": {
@ -7645,6 +7739,14 @@
},
"201": {
"description": "Avatar returned",
"headers": {
"X-NC-IsCustomAvatar": {
"schema": {
"type": "integer",
"format": "int64"
}
}
},
"content": {
"*/*": {
"schema": {

Loading…
Cancel
Save