aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2023-01-05 15:44:37 +0100
committerGitHub <noreply@github.com>2023-01-05 15:44:37 +0100
commit4cda13255d780a7998bc94021918e9ca648f2abd (patch)
tree37a10eb2646a27e014b77bd5c00fbff2cd2b4f3b
parentadef2b85c8c8f771d694dedec2c8509694aee149 (diff)
parentddcee3dbab01b4f4fc163c68a54055facfa8af16 (diff)
downloadnextcloud-server-4cda13255d780a7998bc94021918e9ca648f2abd.tar.gz
nextcloud-server-4cda13255d780a7998bc94021918e9ca648f2abd.zip
Merge pull request #32057 from nextcloud/fix/make-UID-more-unique-for-systemaddressbook
Fix sync errors for card creation with the same uri from different sources
-rw-r--r--apps/dav/lib/CardDAV/Converter.php4
-rw-r--r--apps/dav/lib/CardDAV/SyncService.php2
2 files changed, 4 insertions, 2 deletions
diff --git a/apps/dav/lib/CardDAV/Converter.php b/apps/dav/lib/CardDAV/Converter.php
index 340e3127f0a..8452810c29e 100644
--- a/apps/dav/lib/CardDAV/Converter.php
+++ b/apps/dav/lib/CardDAV/Converter.php
@@ -47,12 +47,14 @@ class Converter {
$userProperties = $this->accountManager->getAccount($user)->getProperties();
$uid = $user->getUID();
+ $backendClassName = $user->getBackendClassName();
$cloudId = $user->getCloudId();
$image = $this->getAvatarImage($user);
$vCard = new VCard();
$vCard->VERSION = '3.0';
- $vCard->UID = $uid;
+ $vCard->UID = md5("$backendClassName:$uid");
+ $vCard->add(new Text($vCard, 'X-NEXTCLOUD-UID', $uid));
$publish = false;
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php
index da798c5768e..d73ec9029f9 100644
--- a/apps/dav/lib/CardDAV/SyncService.php
+++ b/apps/dav/lib/CardDAV/SyncService.php
@@ -274,7 +274,7 @@ class SyncService {
$allCards = $this->backend->getCards($systemAddressBook['id']);
foreach ($allCards as $card) {
$vCard = Reader::read($card['carddata']);
- $uid = $vCard->UID->getValue();
+ $uid = isset($vCard->{'X-NEXTCLOUD-UID'}) ? $vCard->{'X-NEXTCLOUD-UID'}->getValue() : $vCard->UID->getValue();
// load backend and see if user exists
if (!$this->userManager->userExists($uid)) {
$this->deleteUser($card['uri']);