Fix sync errors for duplicate cards with the same UID for different backends

Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
Anna Larch 2022-04-21 21:27:11 +02:00 committed by Anna (Rebase PR Action)
parent 2171e37b7d
commit ddcee3dbab
2 changed files with 4 additions and 2 deletions

View file

@ -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;

View file

@ -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']);