From 92bf4ef422c3d4fcdde0e3538dd81e020b008346 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Fri, 14 Feb 2025 14:25:54 +0100 Subject: [PATCH] fix: change status code from 404 to 204 for missing avatars Switching the response code from 404 to 204 improves compatibility with security appliances like CrowdSec. Since avatar lookups (including external sources) can validly result in a non-existing avatar. Signed-off-by: Daniel Kesselberg --- lib/Controller/AvatarsController.php | 2 +- tests/Unit/Controller/AvatarControllerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Controller/AvatarsController.php b/lib/Controller/AvatarsController.php index 4dc20790b6..431600bfb9 100644 --- a/lib/Controller/AvatarsController.php +++ b/lib/Controller/AvatarsController.php @@ -54,7 +54,7 @@ public function url(string $email): JSONResponse { $avatar = $this->avatarService->getAvatar($email, $this->uid); if (is_null($avatar)) { // No avatar found - $response = new JSONResponse([], Http::STATUS_NOT_FOUND); + $response = new JSONResponse([], Http::STATUS_NO_CONTENT); // Debounce this a bit // (cache for one day) diff --git a/tests/Unit/Controller/AvatarControllerTest.php b/tests/Unit/Controller/AvatarControllerTest.php index b67608172f..c566493cbe 100644 --- a/tests/Unit/Controller/AvatarControllerTest.php +++ b/tests/Unit/Controller/AvatarControllerTest.php @@ -78,7 +78,7 @@ public function testGetUrlNoAvatarFound() { $resp = $this->controller->url($email); - $expected = new JSONResponse([], Http::STATUS_NOT_FOUND); + $expected = new JSONResponse([], Http::STATUS_NO_CONTENT); $expected->cacheFor(24 * 60 * 60, false, true); $this->assertEquals($expected, $resp); }