diff options
author | provokateurin <kate@provokateurin.de> | 2024-06-07 12:09:36 +0200 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2024-06-12 10:27:29 +0200 |
commit | c8e767878d3deac29db18c56896e519dbf17980c (patch) | |
tree | f226b8d55aba27e45501d88299b34013a1ce3c6c | |
parent | 8bed23288b781db22c0825df7fac9f5312fbf6c4 (diff) | |
download | nextcloud-server-c8e767878d3deac29db18c56896e519dbf17980c.tar.gz nextcloud-server-c8e767878d3deac29db18c56896e519dbf17980c.zip |
fix(core): Return X-NC-IsCustomAvatar for guest avatars too
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r-- | core/Controller/AvatarController.php | 6 | ||||
-rw-r--r-- | core/Controller/GuestAvatarController.php | 6 | ||||
-rw-r--r-- | core/openapi.json | 102 |
3 files changed, 109 insertions, 5 deletions
diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php index f65281602bd..f29c9c5ab4f 100644 --- a/core/Controller/AvatarController.php +++ b/core/Controller/AvatarController.php @@ -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}')] diff --git a/core/Controller/GuestAvatarController.php b/core/Controller/GuestAvatarController.php index a2148e5d8c1..3121abc2ca1 100644 --- a/core/Controller/GuestAvatarController.php +++ b/core/Controller/GuestAvatarController.php @@ -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 diff --git a/core/openapi.json b/core/openapi.json index e47819c19be..3bb74224fa1 100644 --- a/core/openapi.json +++ b/core/openapi.json @@ -7319,6 +7319,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", "description": "ID of the user", @@ -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": "" } } } @@ -7387,6 +7422,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", "description": "ID of the user", @@ -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": { |