aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2024-10-18 09:39:36 +0200
committerGitHub <noreply@github.com>2024-10-18 09:39:36 +0200
commit0c67541e76661741ace35b7ac33a3e1a4b120869 (patch)
tree64918b3a32115f0375bf7412bd1f5cde26a59147 /apps/dav
parente65f310bf494f8e024af24497a9b352ab73bc42c (diff)
parent742764bd4e11b3601f56e8032375f082bc1ac626 (diff)
downloadnextcloud-server-0c67541e76661741ace35b7ac33a3e1a4b120869.tar.gz
nextcloud-server-0c67541e76661741ace35b7ac33a3e1a4b120869.zip
Merge pull request #48418 from nextcloud/config-carddav-sync-request-timeout
feat: configurable request timeout for carddav sync
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php10
-rw-r--r--apps/dav/tests/unit/CardDAV/SyncServiceTest.php12
2 files changed, 17 insertions, 5 deletions
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index 05a08d08286..a10c830ec79 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -10,7 +10,9 @@ namespace OCA\DAV\CardDAV;
use OCP\AppFramework\Db\TTransactional;
use OCP\AppFramework\Http;
+use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserManager;
@@ -33,13 +35,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 +51,7 @@ class SyncService {
$this->certPath = '';
$this->dbConnection = $dbConnection;
$this->clientService = $clientService;
+ $this->config = $config;
}
/**
@@ -150,7 +155,8 @@ class SyncService {
$options = [
'auth' => [$userName, $sharedSecret],
'body' => $this->buildSyncCollectionRequestBody($syncToken),
- 'headers' => ['Content-Type' => 'application/xml']
+ 'headers' => ['Content-Type' => 'application/xml'],
+ 'timeout' => $this->config->getSystemValueInt('carddav_sync_request_timeout', IClient::DEFAULT_REQUEST_TIMEOUT)
];
$response = $client->request(
diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
index db99f73306d..5af42e2ea4e 100644
--- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php
@@ -16,6 +16,7 @@ use OCA\DAV\CardDAV\Converter;
use OCA\DAV\CardDAV\SyncService;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserManager;
@@ -33,6 +34,7 @@ class SyncServiceTest extends TestCase {
protected LoggerInterface $logger;
protected Converter $converter;
protected IClient $client;
+ protected IConfig $config;
protected SyncService $service;
public function setUp(): void {
$addressBook = [
@@ -53,6 +55,7 @@ class SyncServiceTest extends TestCase {
$this->logger = new NullLogger();
$this->converter = $this->createMock(Converter::class);
$this->client = $this->createMock(IClient::class);
+ $this->config = $this->createMock(IConfig::class);
$clientService = $this->createMock(IClientService::class);
$clientService->method('newClient')
@@ -64,7 +67,8 @@ class SyncServiceTest extends TestCase {
$this->dbConnection,
$this->logger,
$this->converter,
- $clientService
+ $clientService,
+ $this->config
);
}
@@ -305,8 +309,9 @@ END:VCARD';
$logger = $this->getMockBuilder(LoggerInterface::class)->disableOriginalConstructor()->getMock();
$converter = $this->createMock(Converter::class);
$clientService = $this->createMock(IClientService::class);
+ $config = $this->createMock(IConfig::class);
- $ss = new SyncService($backend, $userManager, $dbConnection, $logger, $converter, $clientService);
+ $ss = new SyncService($backend, $userManager, $dbConnection, $logger, $converter, $clientService, $config);
$ss->ensureSystemAddressBookExists('principals/users/adam', 'contacts', []);
}
@@ -360,8 +365,9 @@ END:VCARD';
->willReturn($this->createMock(VCard::class));
$clientService = $this->createMock(IClientService::class);
+ $config = $this->createMock(IConfig::class);
- $ss = new SyncService($backend, $userManager, $dbConnection, $logger, $converter, $clientService);
+ $ss = new SyncService($backend, $userManager, $dbConnection, $logger, $converter, $clientService, $config);
$ss->updateUser($user);
$ss->updateUser($user);