Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]>
  • Loading branch information
kesselb committed Feb 20, 2025
commit d9f856ca49e632903da710e7d3821dd75e88aaa3
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