diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php index 3126b2600d9..5d117f6ae7f 100644 --- a/core/Controller/AvatarController.php +++ b/core/Controller/AvatarController.php @@ -55,7 +55,7 @@ class AvatarController extends Controller { * Get the dark avatar * * @param string $userId ID of the user - * @param int $size Size of the avatar + * @param 64|512 $size Size of the avatar * @param bool $guestFallback Fallback to guest avatar if not found * @return FileDisplayResponse|JSONResponse, array{}>|Response * @@ -89,7 +89,7 @@ class AvatarController extends Controller { ); } catch (\Exception $e) { if ($guestFallback) { - return $this->guestAvatarController->getAvatarDark($userId, (string)$size); + return $this->guestAvatarController->getAvatarDark($userId, $size); } return new JSONResponse([], Http::STATUS_NOT_FOUND); } @@ -106,7 +106,7 @@ class AvatarController extends Controller { * Get the avatar * * @param string $userId ID of the user - * @param int $size Size of the avatar + * @param 64|512 $size Size of the avatar * @param bool $guestFallback Fallback to guest avatar if not found * @return FileDisplayResponse|JSONResponse, array{}>|Response * @@ -140,7 +140,7 @@ class AvatarController extends Controller { ); } catch (\Exception $e) { if ($guestFallback) { - return $this->guestAvatarController->getAvatar($userId, (string)$size); + return $this->guestAvatarController->getAvatar($userId, $size); } return new JSONResponse([], Http::STATUS_NOT_FOUND); } diff --git a/core/Controller/GuestAvatarController.php b/core/Controller/GuestAvatarController.php index 6a7edc9cfcc..e87112726f2 100644 --- a/core/Controller/GuestAvatarController.php +++ b/core/Controller/GuestAvatarController.php @@ -36,7 +36,7 @@ class GuestAvatarController extends Controller { * Returns a guest avatar image response * * @param string $guestName The guest name, e.g. "Albert" - * @param string $size The desired avatar size, e.g. 64 for 64x64px + * @param 64|512 $size The desired avatar size, e.g. 64 for 64x64px * @param bool|null $darkTheme Return dark avatar * @return FileDisplayResponse|Response * @@ -46,8 +46,7 @@ class GuestAvatarController extends Controller { #[PublicPage] #[NoCSRFRequired] #[FrontpageRoute(verb: 'GET', url: '/avatar/guest/{guestName}/{size}')] - public function getAvatar(string $guestName, string $size, ?bool $darkTheme = false) { - $size = (int) $size; + public function getAvatar(string $guestName, int $size, ?bool $darkTheme = false) { $darkTheme = $darkTheme ?? false; if ($size <= 64) { @@ -89,7 +88,7 @@ class GuestAvatarController extends Controller { * Returns a dark guest avatar image response * * @param string $guestName The guest name, e.g. "Albert" - * @param string $size The desired avatar size, e.g. 64 for 64x64px + * @param 64|512 $size The desired avatar size, e.g. 64 for 64x64px * @return FileDisplayResponse|Response * * 200: Custom avatar returned @@ -98,7 +97,7 @@ class GuestAvatarController extends Controller { #[PublicPage] #[NoCSRFRequired] #[FrontpageRoute(verb: 'GET', url: '/avatar/guest/{guestName}/{size}/dark')] - public function getAvatarDark(string $guestName, string $size) { + public function getAvatarDark(string $guestName, int $size) { return $this->getAvatar($guestName, $size, true); } } diff --git a/core/openapi-full.json b/core/openapi-full.json index dbeb48dbe35..47cef87379b 100644 --- a/core/openapi-full.json +++ b/core/openapi-full.json @@ -7567,7 +7567,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 64, + 512 + ] } } ], @@ -7674,7 +7678,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 64, + 512 + ] } } ], @@ -7914,7 +7922,12 @@ "description": "The desired avatar size, e.g. 64 for 64x64px", "required": true, "schema": { - "type": "string" + "type": "integer", + "format": "int64", + "enum": [ + 64, + 512 + ] } } ], @@ -7995,7 +8008,12 @@ "description": "The desired avatar size, e.g. 64 for 64x64px", "required": true, "schema": { - "type": "string" + "type": "integer", + "format": "int64", + "enum": [ + 64, + 512 + ] } } ], diff --git a/core/openapi.json b/core/openapi.json index abe21707db3..5d8a66cac21 100644 --- a/core/openapi.json +++ b/core/openapi.json @@ -7567,7 +7567,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 64, + 512 + ] } } ], @@ -7674,7 +7678,11 @@ "required": true, "schema": { "type": "integer", - "format": "int64" + "format": "int64", + "enum": [ + 64, + 512 + ] } } ], @@ -7914,7 +7922,12 @@ "description": "The desired avatar size, e.g. 64 for 64x64px", "required": true, "schema": { - "type": "string" + "type": "integer", + "format": "int64", + "enum": [ + 64, + 512 + ] } } ], @@ -7995,7 +8008,12 @@ "description": "The desired avatar size, e.g. 64 for 64x64px", "required": true, "schema": { - "type": "string" + "type": "integer", + "format": "int64", + "enum": [ + 64, + 512 + ] } } ],