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
This commit is contained in:
John Molakvoæ 2023-01-05 15:44:37 +01:00 committed by GitHub
commit 4cda13255d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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']);