Merge pull request #19696 from nextcloud/backport/19694/stable18
[stable18] Also cache avatars when it's not allowed
This commit is contained in:
commit
fcb64dfd53
1 changed files with 6 additions and 4 deletions
|
@ -134,13 +134,15 @@ class AvatarController extends Controller {
|
||||||
|
|
||||||
if ($scope !== IAccountManager::VISIBILITY_PUBLIC && $this->userId === null) {
|
if ($scope !== IAccountManager::VISIBILITY_PUBLIC && $this->userId === null) {
|
||||||
// Public avatar access is not allowed
|
// 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 {
|
try {
|
||||||
$avatar = $this->avatarManager->getAvatar($userId);
|
$avatar = $this->avatarManager->getAvatar($userId);
|
||||||
$avatarFile = $avatar->getFile($size);
|
$avatarFile = $avatar->getFile($size);
|
||||||
$resp = new FileDisplayResponse(
|
$response = new FileDisplayResponse(
|
||||||
$avatarFile,
|
$avatarFile,
|
||||||
$avatar->isCustomAvatar() ? Http::STATUS_OK : Http::STATUS_CREATED,
|
$avatar->isCustomAvatar() ? Http::STATUS_OK : Http::STATUS_CREATED,
|
||||||
['Content-Type' => $avatarFile->getMimeType()]
|
['Content-Type' => $avatarFile->getMimeType()]
|
||||||
|
@ -150,8 +152,8 @@ class AvatarController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache for 30 minutes
|
// Cache for 30 minutes
|
||||||
$resp->cacheFor(1800);
|
$response->cacheFor(1800);
|
||||||
return $resp;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue