Skip to content

Commit a7b4fab

Browse files
kesselbbackportbot[bot]
authored andcommitted
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 <[email protected]>
1 parent 871615e commit a7b4fab

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/Controller/AvatarsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function url(string $email): JSONResponse {
6767
$avatar = $this->avatarService->getAvatar($email, $this->uid);
6868
if (is_null($avatar)) {
6969
// No avatar found
70-
$response = new JSONResponse([], Http::STATUS_NOT_FOUND);
70+
$response = new JSONResponse([], Http::STATUS_NO_CONTENT);
7171

7272
// Debounce this a bit
7373
// (cache for one day)

tests/Unit/Controller/AvatarControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function testGetUrlNoAvatarFound() {
9595

9696
$resp = $this->controller->url($email);
9797

98-
$expected = new JSONResponse([], Http::STATUS_NOT_FOUND);
98+
$expected = new JSONResponse([], Http::STATUS_NO_CONTENT);
9999
$expected->cacheFor(24 * 60 * 60, false, true);
100100
$this->assertEquals($expected, $resp);
101101
}

0 commit comments

Comments
 (0)