]> source.dussan.org Git - nextcloud-server.git/commitdiff
Also cache avatars when it's not allowed 19694/head
authorJoas Schilling <coding@schilljs.com>
Fri, 28 Feb 2020 09:44:15 +0000 (10:44 +0100)
committerJoas Schilling <coding@schilljs.com>
Fri, 28 Feb 2020 09:44:15 +0000 (10:44 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
core/Controller/AvatarController.php

index 7ec338467c6b890e89717b866301d6d1ca019aa0..5ecdc91db249f2e3aa718414579661c3aa84a781 100644 (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;
        }
 
        /**