diff options
-rw-r--r-- | lib/Controller/AccountsController.php | 2 | ||||
-rw-r--r-- | lib/Controller/AutoCompleteController.php | 3 | ||||
-rw-r--r-- | lib/Controller/AutoConfigController.php | 10 | ||||
-rw-r--r-- | lib/Controller/AvatarsController.php | 2 | ||||
-rw-r--r-- | lib/Controller/ContactIntegrationController.php | 4 | ||||
-rwxr-xr-x | lib/Controller/MessagesController.php | 10 | ||||
-rw-r--r-- | lib/Http/ProxyDownloadResponse.php | 2 | ||||
-rw-r--r-- | tests/Unit/Controller/AutoCompleteControllerTest.php | 2 | ||||
-rw-r--r-- | tests/Unit/Controller/AvatarControllerTest.php | 2 | ||||
-rw-r--r-- | tests/Unit/Controller/MessagesControllerTest.php | 4 |
10 files changed, 24 insertions, 17 deletions
diff --git a/lib/Controller/AccountsController.php b/lib/Controller/AccountsController.php index f70cf6e41..4de62fa85 100644 --- a/lib/Controller/AccountsController.php +++ b/lib/Controller/AccountsController.php @@ -402,6 +402,6 @@ class AccountsController extends Controller { if ($quota === null) { return MailJsonResponse::fail([], Http::STATUS_NOT_IMPLEMENTED); } - return MailJsonResponse::success($quota); + return MailJsonResponse::success($quota)->cacheFor(5 * 60, false, true); } } diff --git a/lib/Controller/AutoCompleteController.php b/lib/Controller/AutoCompleteController.php index 4e1c60b25..2edb7b6dc 100644 --- a/lib/Controller/AutoCompleteController.php +++ b/lib/Controller/AutoCompleteController.php @@ -57,6 +57,7 @@ class AutoCompleteController extends Controller { return new JSONResponse([]); } - return new JSONResponse($this->service->findMatches($this->userId, $term)); + return (new JSONResponse($this->service->findMatches($this->userId, $term))) + ->cacheFor(5 * 60, false, true); } } diff --git a/lib/Controller/AutoConfigController.php b/lib/Controller/AutoConfigController.php index 796f7a42a..1c2517753 100644 --- a/lib/Controller/AutoConfigController.php +++ b/lib/Controller/AutoConfigController.php @@ -62,20 +62,22 @@ class AutoConfigController extends Controller { public function queryIspdb(string $email): JsonResponse { $rfc822Address = new Horde_Mail_Rfc822_Address($email); if (!$rfc822Address->valid) { - return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY); + return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY) + ->cacheFor(60 * 60, false, true); } $config = $this->ispDb->query($rfc822Address->host, $rfc822Address); - return JsonResponse::success($config); + return JsonResponse::success($config)->cacheFor(5 * 60, false, true); } public function queryMx(string $email): JsonResponse { $rfc822Address = new Horde_Mail_Rfc822_Address($email); if (!$rfc822Address->valid) { - return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY); + return JsonResponse::fail('Invalid email address', Http::STATUS_UNPROCESSABLE_ENTITY) + ->cacheFor(60 * 60, false, true); } return JsonResponse::success( $this->mxRecord->query($rfc822Address->host), - ); + )->cacheFor(5 * 60, false, true); } public function testConnectivity(string $host, int $port): JsonResponse { diff --git a/lib/Controller/AvatarsController.php b/lib/Controller/AvatarsController.php index 6bcae9348..bd52d011c 100644 --- a/lib/Controller/AvatarsController.php +++ b/lib/Controller/AvatarsController.php @@ -73,7 +73,7 @@ class AvatarsController extends Controller { // Debounce this a bit // (cache for one day) - $response->cacheFor(24 * 60 * 60); + $response->cacheFor(24 * 60 * 60, false, true); return $response; } diff --git a/lib/Controller/ContactIntegrationController.php b/lib/Controller/ContactIntegrationController.php index a5537ca5b..a95be9f2c 100644 --- a/lib/Controller/ContactIntegrationController.php +++ b/lib/Controller/ContactIntegrationController.php @@ -49,7 +49,7 @@ class ContactIntegrationController extends Controller { * @return JSONResponse */ public function match(string $mail): JSONResponse { - return new JSONResponse($this->service->findMatches($mail)); + return (new JSONResponse($this->service->findMatches($mail)))->cacheFor(60 * 60, false, true); } /** @@ -93,6 +93,6 @@ class ContactIntegrationController extends Controller { */ public function autoComplete(string $term): JSONResponse { $res = $this->service->autoComplete($term); - return new JSONResponse($res); + return (new JSONResponse($res))->cacheFor(60 * 60, false, true); } } diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index a0f68fe9e..d314c7f04 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -264,7 +264,7 @@ class MessagesController extends Controller { $response = new JSONResponse($json); // Enable caching - $response->cacheFor(60 * 60); + $response->cacheFor(60 * 60, false, true); return $response; } @@ -288,7 +288,9 @@ class MessagesController extends Controller { return new JSONResponse([], Http::STATUS_FORBIDDEN); } - return new JsonResponse($this->itineraryService->extract($account, $mailbox, $message->getUid())); + $response = new JsonResponse($this->itineraryService->extract($account, $mailbox, $message->getUid())); + $response->cacheFor(24 * 60 * 60, false, true); + return $response; } private function isSenderTrusted(Message $message): bool { @@ -431,7 +433,7 @@ class MessagesController extends Controller { ]); // Enable caching - $response->cacheFor(60 * 60); + $response->cacheFor(60 * 60, false, true); return $response; } @@ -524,7 +526,7 @@ class MessagesController extends Controller { $htmlResponse->setContentSecurityPolicy($policy); // Enable caching - $htmlResponse->cacheFor(60 * 60); + $htmlResponse->cacheFor(60 * 60, false, true); return $htmlResponse; } catch (Exception $ex) { diff --git a/lib/Http/ProxyDownloadResponse.php b/lib/Http/ProxyDownloadResponse.php index fca52602c..8da259f26 100644 --- a/lib/Http/ProxyDownloadResponse.php +++ b/lib/Http/ProxyDownloadResponse.php @@ -48,7 +48,7 @@ class ProxyDownloadResponse extends DownloadResponse { $now = (new DateTime('now'))->getTimestamp(); $expires = (new DateTime('now + 11 months'))->getTimestamp(); - $this->cacheFor($expires - $now); + $this->cacheFor($expires - $now, false, true); } /** diff --git a/tests/Unit/Controller/AutoCompleteControllerTest.php b/tests/Unit/Controller/AutoCompleteControllerTest.php index d2d31c4ec..ed8c56c1f 100644 --- a/tests/Unit/Controller/AutoCompleteControllerTest.php +++ b/tests/Unit/Controller/AutoCompleteControllerTest.php @@ -63,6 +63,6 @@ class AutoCompleteControllerTest extends TestCase { $response = $this->controller->index($term); - $this->assertEquals(new JSONResponse($result), $response); + $this->assertEquals((new JSONResponse($result))->getData(), $response->getData()); } } diff --git a/tests/Unit/Controller/AvatarControllerTest.php b/tests/Unit/Controller/AvatarControllerTest.php index 66a425996..fbac55030 100644 --- a/tests/Unit/Controller/AvatarControllerTest.php +++ b/tests/Unit/Controller/AvatarControllerTest.php @@ -96,7 +96,7 @@ class AvatarControllerTest extends TestCase { $resp = $this->controller->url($email); $expected = new JSONResponse([], Http::STATUS_NOT_FOUND); - $expected->cacheFor(24 * 60 * 60); + $expected->cacheFor(24 * 60 * 60, false, true); $this->assertEquals($expected, $resp); } diff --git a/tests/Unit/Controller/MessagesControllerTest.php b/tests/Unit/Controller/MessagesControllerTest.php index af0d15faa..ae04047bc 100644 --- a/tests/Unit/Controller/MessagesControllerTest.php +++ b/tests/Unit/Controller/MessagesControllerTest.php @@ -185,7 +185,7 @@ class MessagesControllerTest extends TestCase { \OC::$server->offsetSet(ITimeFactory::class, $this->oldFactory); } - public function testGetHtmlBody() { + public function testGetHtmlBody(): void { $accountId = 17; $mailboxId = 13; $folderId = 'testfolder'; @@ -244,7 +244,9 @@ class MessagesControllerTest extends TestCase { $policy->disallowFontDomain('\'self\''); $policy->disallowMediaDomain('\'self\''); $expectedPlainResponse->setContentSecurityPolicy($policy); + $expectedPlainResponse->cacheFor(60 * 60, false, true); $expectedRichResponse->setContentSecurityPolicy($policy); + $expectedRichResponse->cacheFor(60 * 60, false, true); $actualPlainResponse = $this->controller->getHtmlBody($messageId, true); $actualRichResponse = $this->controller->getHtmlBody($messageId, false); |