From 7b1d30c126130aaf427d6dc3c976519fda6c8320 Mon Sep 17 00:00:00 2001 From: Pablo Zmdl Date: Fri, 27 Sep 2024 13:59:09 +0200 Subject: [PATCH] feat: configurable request timeout for carddav sync Big federated setups may need a longer timeout, which they now can configure. Signed-off-by: Pablo Zmdl Co-authored-by: Josh --- apps/dav/lib/CardDAV/SyncService.php | 9 +++++++-- config/config.sample.php | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php index 5f8752a9d492c..461067ebd4570 100644 --- a/apps/dav/lib/CardDAV/SyncService.php +++ b/apps/dav/lib/CardDAV/SyncService.php @@ -11,6 +11,7 @@ use OCP\AppFramework\Db\TTransactional; use OCP\AppFramework\Http; use OCP\Http\Client\IClientService; +use OCP\IConfig; use OCP\IDBConnection; use OCP\IUser; use OCP\IUserManager; @@ -33,13 +34,15 @@ class SyncService { private Converter $converter; protected string $certPath; private IClientService $clientService; + private IConfig $config; public function __construct(CardDavBackend $backend, IUserManager $userManager, IDBConnection $dbConnection, LoggerInterface $logger, Converter $converter, - IClientService $clientService) { + IClientService $clientService, + IConfig $config) { $this->backend = $backend; $this->userManager = $userManager; $this->logger = $logger; @@ -47,6 +50,7 @@ public function __construct(CardDavBackend $backend, $this->certPath = ''; $this->dbConnection = $dbConnection; $this->clientService = $clientService; + $this->config = $config; } /** @@ -121,7 +125,8 @@ protected function requestSyncReport(string $url, string $userName, string $addr 'auth' => [$userName, $sharedSecret], 'base_uri' => $url, 'body' => $this->buildSyncCollectionRequestBody($syncToken), - 'headers' => ['Content-Type' => 'application/xml'] + 'headers' => ['Content-Type' => 'application/xml'], + 'timeout' => $this->config->getSystemValueInt('carddav_sync_request_timeout', 30) ]; $response = $client->request( diff --git a/config/config.sample.php b/config/config.sample.php index 21a77a8cbf646..709c1fb73c63a 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -340,6 +340,13 @@ */ 'davstorage.request_timeout' => 30, +/** + * The timeout in seconds for synchronizing address books, e.g. federated system address books (as run by `occ federation:sync-addressbooks`). + * + * Defaults to ``30`` seconds + */ +'carddav_sync_request_timeout' => 30, + /** * `true` enabled a relaxed session timeout, where the session timeout would no longer be * handled by Nextcloud but by either the PHP garbage collection or the expiration of