aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federation/lib/SyncFederationAddressBooks.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federation/lib/SyncFederationAddressBooks.php')
-rw-r--r--apps/federation/lib/SyncFederationAddressBooks.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/apps/federation/lib/SyncFederationAddressBooks.php b/apps/federation/lib/SyncFederationAddressBooks.php
index 759b59183aa..87419a5ba54 100644
--- a/apps/federation/lib/SyncFederationAddressBooks.php
+++ b/apps/federation/lib/SyncFederationAddressBooks.php
@@ -23,12 +23,10 @@
*/
namespace OCA\Federation;
+use OC\OCS\DiscoveryService;
use OCA\DAV\CardDAV\SyncService;
use OCP\AppFramework\Http;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Helper\ProgressBar;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
+use OCP\OCS\IDiscoveryService;
class SyncFederationAddressBooks {
@@ -38,13 +36,21 @@ class SyncFederationAddressBooks {
/** @var SyncService */
private $syncService;
+ /** @var DiscoveryService */
+ private $ocsDiscoveryService;
+
/**
* @param DbHandler $dbHandler
* @param SyncService $syncService
+ * @param IDiscoveryService $ocsDiscoveryService
*/
- function __construct(DbHandler $dbHandler, SyncService $syncService) {
+ public function __construct(DbHandler $dbHandler,
+ SyncService $syncService,
+ IDiscoveryService $ocsDiscoveryService
+ ) {
$this->syncService = $syncService;
$this->dbHandler = $dbHandler;
+ $this->ocsDiscoveryService = $ocsDiscoveryService;
}
/**
@@ -59,6 +65,10 @@ class SyncFederationAddressBooks {
$sharedSecret = $trustedServer['shared_secret'];
$syncToken = $trustedServer['sync_token'];
+ $endPoints = $this->ocsDiscoveryService->discover($url, 'FEDERATED_SHARING');
+ $cardDavUser = isset($endPoints['carddav-user']) ? $endPoints['carddav-user'] : 'system';
+ $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system';
+
if (is_null($sharedSecret)) {
continue;
}
@@ -68,7 +78,7 @@ class SyncFederationAddressBooks {
'{DAV:}displayname' => $url
];
try {
- $newToken = $this->syncService->syncRemoteAddressBook($url, 'system', $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties);
+ $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties);
if ($newToken !== $syncToken) {
$this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken);
}