diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-08-31 14:13:37 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-08-31 18:02:57 +0200 |
commit | 1ab66988bc6e5dca0b0b18ad9366880124fb28e1 (patch) | |
tree | ebf692156207f422bef27761a5f36c7a8d4b3cda /lib/private/Collaboration | |
parent | 80f6a5834ab9e679c1a0df6a1aee82107ca5cfe3 (diff) | |
download | nextcloud-server-1ab66988bc6e5dca0b0b18ad9366880124fb28e1.tar.gz nextcloud-server-1ab66988bc6e5dca0b0b18ad9366880124fb28e1.zip |
Inject all dependnencies and increase cache timeout
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Collaboration')
3 files changed, 12 insertions, 6 deletions
diff --git a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php index ecb7229e21e..39cdb62b09a 100644 --- a/lib/private/Collaboration/Reference/File/FileReferenceProvider.php +++ b/lib/private/Collaboration/Reference/File/FileReferenceProvider.php @@ -103,7 +103,7 @@ class FileReferenceProvider implements IReferenceProvider { /** * @throws NotFoundException */ - private function fetchReference(Reference $reference) { + private function fetchReference(Reference $reference): void { if ($this->userId === null) { throw new NotFoundException(); } diff --git a/lib/private/Collaboration/Reference/LinkReferenceProvider.php b/lib/private/Collaboration/Reference/LinkReferenceProvider.php index 0c2052b6d7d..36fbdd0b168 100644 --- a/lib/private/Collaboration/Reference/LinkReferenceProvider.php +++ b/lib/private/Collaboration/Reference/LinkReferenceProvider.php @@ -35,7 +35,9 @@ use OCP\Collaboration\Reference\IReferenceProvider; use OCP\Files\AppData\IAppDataFactory; use OCP\Files\NotFoundException; use OCP\Http\Client\IClientService; +use OCP\IRequest; use OCP\IURLGenerator; +use OCP\IUserSession; use Psr\Log\LoggerInterface; class LinkReferenceProvider implements IReferenceProvider { @@ -56,14 +58,18 @@ class LinkReferenceProvider implements IReferenceProvider { private IAppDataFactory $appDataFactory; private IURLGenerator $urlGenerator; private Limiter $limiter; + private IUserSession $userSession; + private IRequest $request; - public function __construct(IClientService $clientService, LoggerInterface $logger, SystemConfig $systemConfig, IAppDataFactory $appDataFactory, IURLGenerator $urlGenerator, Limiter $limiter) { + public function __construct(IClientService $clientService, LoggerInterface $logger, SystemConfig $systemConfig, IAppDataFactory $appDataFactory, IURLGenerator $urlGenerator, Limiter $limiter, IUserSession $userSession, IRequest $request) { $this->clientService = $clientService; $this->logger = $logger; $this->systemConfig = $systemConfig; $this->appDataFactory = $appDataFactory; $this->urlGenerator = $urlGenerator; $this->limiter = $limiter; + $this->userSession = $userSession; + $this->request = $request; } public function matchReference(string $referenceText): bool { @@ -84,13 +90,13 @@ class LinkReferenceProvider implements IReferenceProvider { return null; } - private function fetchReference(Reference $reference) { + private function fetchReference(Reference $reference): void { try { - $user = \OC::$server->getUserSession()->getUser(); + $user = $this->userSession->getUser(); if ($user) { $this->limiter->registerUserRequest('opengraph', 10, 120, $user); } else { - $this->limiter->registerAnonRequest('opengraph', 10, 120, \OC::$server->getRequest()->getRemoteAddress()); + $this->limiter->registerAnonRequest('opengraph', 10, 120, $this->request->getRemoteAddress()); } } catch (RateLimitExceededException $e) { return; diff --git a/lib/private/Collaboration/Reference/ReferenceManager.php b/lib/private/Collaboration/Reference/ReferenceManager.php index 562c9944651..304d693804f 100644 --- a/lib/private/Collaboration/Reference/ReferenceManager.php +++ b/lib/private/Collaboration/Reference/ReferenceManager.php @@ -37,7 +37,7 @@ use Psr\Log\LoggerInterface; use Throwable; class ReferenceManager implements IReferenceManager { - public const CACHE_TTL = 60; + public const CACHE_TTL = 3600; /** @var IReferenceProvider[]|null */ private ?array $providers = null; |