summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php31
1 files changed, 17 insertions, 14 deletions
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index 477e912a797..b6f57753431 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -75,6 +75,7 @@ class SyncService {
/**
* @param string $url
* @param string $userName
+ * @param string $addressBookUrl
* @param string $sharedSecret
* @param string $syncToken
* @param int $targetBookId
@@ -83,14 +84,14 @@ class SyncService {
* @return string
* @throws \Exception
*/
- public function syncRemoteAddressBook($url, $userName, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) {
+ public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) {
// 1. create addressbook
$book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties);
$addressBookId = $book['id'];
// 2. query changes
try {
- $response = $this->requestSyncReport($url, $userName, $sharedSecret, $syncToken);
+ $response = $this->requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken);
} catch (ClientHttpException $ex) {
if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {
// remote server revoked access to the address book, remove it
@@ -105,7 +106,7 @@ class SyncService {
foreach ($response['response'] as $resource => $status) {
$cardUri = basename($resource);
if (isset($status[200])) {
- $vCard = $this->download($url, $sharedSecret, $resource);
+ $vCard = $this->download($url, $userName, $sharedSecret, $resource);
$existingCard = $this->backend->getCard($addressBookId, $cardUri);
if ($existingCard === false) {
$this->backend->createCard($addressBookId, $cardUri, $vCard['body']);
@@ -162,6 +163,7 @@ class SyncService {
/**
* @param string $url
* @param string $userName
+ * @param string $addressBookUrl
* @param string $sharedSecret
* @return Client
*/
@@ -185,31 +187,32 @@ class SyncService {
/**
* @param string $url
* @param string $userName
+ * @param string $addressBookUrl
* @param string $sharedSecret
* @param string $syncToken
* @return array
*/
- protected function requestSyncReport($url, $userName, $sharedSecret, $syncToken) {
- $client = $this->getClient($url, $userName, $sharedSecret);
+ protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
+ $client = $this->getClient($url, $userName, $sharedSecret);
- $addressBookUrl = "remote.php/dav/addressbooks/system/system/system";
- $body = $this->buildSyncCollectionRequestBody($syncToken);
+ $body = $this->buildSyncCollectionRequestBody($syncToken);
- $response = $client->request('REPORT', $addressBookUrl, $body, [
- 'Content-Type' => 'application/xml'
- ]);
+ $response = $client->request('REPORT', $addressBookUrl, $body, [
+ 'Content-Type' => 'application/xml'
+ ]);
- return $this->parseMultiStatus($response['body']);
- }
+ return $this->parseMultiStatus($response['body']);
+ }
/**
* @param string $url
+ * @param string $userName
* @param string $sharedSecret
* @param string $resourcePath
* @return array
*/
- protected function download($url, $sharedSecret, $resourcePath) {
- $client = $this->getClient($url, 'system', $sharedSecret);
+ protected function download($url, $userName, $sharedSecret, $resourcePath) {
+ $client = $this->getClient($url, $userName, $sharedSecret);
return $client->request('GET', $resourcePath);
}