Skip to content

Commit

Permalink
fixup! feat(cardav): support result truncation for addressbook federa…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 authored and AndyScherzinger committed Feb 5, 2025
1 parent 1e02d6b commit eaad0d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/federation/lib/SyncFederationAddressBooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function syncThemAll(\Closure $callback) {
try {
$newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties);
if ($newToken !== $syncToken) {
if (strpos($newToken, 'init') !== false) {
$newToken = $this->syncTruncatedAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $newToken, $targetBookId, $targetPrincipal, $targetBookProperties);
}
$this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken);
} else {
$this->logger->debug("Sync Token for $url unchanged from previous sync");
Expand All @@ -76,4 +79,12 @@ public function syncThemAll(\Closure $callback) {
}
}
}

private function syncTruncatedAddressBook(string $url, string $cardDavUser, string $addressBookUrl, string $sharedSecret, string $syncToken, int $targetBookId, string $targetPrincipal, array $targetBookProperties): string {
$newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties);
while(strpos($newToken, 'init') !== false) {
$newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties);
}
return $newToken;
}
}

0 comments on commit eaad0d0

Please sign in to comment.