diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-02-24 16:09:52 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-11 15:04:01 +0200 |
commit | d5dec527c964fd08b91f9ab6ffeea228ca214ad6 (patch) | |
tree | a4a4022d5ca1c0929d9ddcd7813a1610f923938e /apps/federation/lib/SyncFederationAddressBooks.php | |
parent | 930c507d893a85581f5da8370c3daeb30e17efdc (diff) | |
download | nextcloud-server-d5dec527c964fd08b91f9ab6ffeea228ca214ad6.tar.gz nextcloud-server-d5dec527c964fd08b91f9ab6ffeea228ca214ad6.zip |
get addressbook url and carddav user from remote server
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federation/lib/SyncFederationAddressBooks.php')
-rw-r--r-- | apps/federation/lib/SyncFederationAddressBooks.php | 22 |
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); } |