Merge pull request #39525 from nextcloud/fix/set-owner-principal-for-SAB

fix(CardDAV): set owner-principal, displayname properties for SAB
This commit is contained in:
Thomas Citharel 2023-08-16 10:17:19 +02:00 committed by GitHub
commit 6d0dabedd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 5 deletions

View file

@ -223,10 +223,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable, IMov
}
public function propPatch(PropPatch $propPatch) {
// shared address books will be handled by
// \OCA\DAV\DAV\CustomPropertiesBackend::propPatch
// to save values in db table instead of dav object
if (!$this->isShared()) {
if (!isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
parent::propPatch($propPatch);
}
}

View file

@ -311,10 +311,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
];
// system address books are always read only
if ($principal === 'principals/system/system') {
$addressBook['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'] = $row['principaluri'];
$addressBook['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'] = true;
}

View file

@ -208,6 +208,11 @@ class Principal implements BackendInterface {
'{DAV:}displayname' => $group->getDisplayName(),
];
}
} elseif ($prefix === 'principals/system') {
return [
'uri' => 'principals/system/' . $name,
'{DAV:}displayname' => $this->languageFactory->get('dav')->t("Accounts"),
];
}
return null;
}

View file

@ -124,7 +124,6 @@ class AddressBookTest extends TestCase {
$backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
$backend->expects($this->atLeast(1))->method('updateAddressBook');
$addressBookInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
'{DAV:}displayname' => 'Test address book',
'principaluri' => 'user1',
'id' => 666,