Merge pull request #19694 from nextcloud/bugfix/noid/cache-404-avatar-responses-too

Also cache avatars when it's not allowed
This commit is contained in:
Joas Schilling 2020-02-28 12:27:58 +01:00 committed by GitHub
commit 7b7d69d5da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -134,13 +134,15 @@ class AvatarController extends Controller {
if ($scope !== IAccountManager::VISIBILITY_PUBLIC && $this->userId === null) {
// Public avatar access is not allowed
return new JSONResponse([], Http::STATUS_NOT_FOUND);
$response = new JSONResponse([], Http::STATUS_NOT_FOUND);
$response->cacheFor(1800);
return $response;
}
try {
$avatar = $this->avatarManager->getAvatar($userId);
$avatarFile = $avatar->getFile($size);
$resp = new FileDisplayResponse(
$response = new FileDisplayResponse(
$avatarFile,
$avatar->isCustomAvatar() ? Http::STATUS_OK : Http::STATUS_CREATED,
['Content-Type' => $avatarFile->getMimeType()]
@ -150,8 +152,8 @@ class AvatarController extends Controller {
}
// Cache for 30 minutes
$resp->cacheFor(1800);
return $resp;
$response->cacheFor(1800);
return $response;
}
/**