Skip to content

Commit

Permalink
fix: change status code from 404 to 204 for missing avatars
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kesselb authored and backportbot[bot] committed Feb 14, 2025
1 parent 871615e commit a7b4fab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/AvatarsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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)
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Controller/AvatarControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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);
}
Expand Down

0 comments on commit a7b4fab

Please sign in to comment.