From 6bd78917d31ab9932a9f394197007feea46bcbd8 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Fri, 21 Jul 2023 12:33:00 +0200 Subject: [PATCH] fix(CardDAV): set owner-principal, displayname properties for SAB Signed-off-by: Anna Larch --- apps/dav/lib/CardDAV/AddressBook.php | 5 +---- apps/dav/lib/CardDAV/CardDavBackend.php | 2 ++ apps/dav/lib/Connector/Sabre/Principal.php | 5 +++++ apps/dav/tests/unit/CardDAV/AddressBookTest.php | 1 - 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/dav/lib/CardDAV/AddressBook.php b/apps/dav/lib/CardDAV/AddressBook.php index b0fb8c8ee5c4b..468961b958e71 100644 --- a/apps/dav/lib/CardDAV/AddressBook.php +++ b/apps/dav/lib/CardDAV/AddressBook.php @@ -223,10 +223,7 @@ public function delete() { } 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); } } diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 045ad4d1385ba..d7bad8d74cadf 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -311,10 +311,12 @@ public function getAddressBooksByUri(string $principal, string $addressBookUri): '{' . 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; } diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 0a88228831421..b1f1da6f63df4 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -208,6 +208,11 @@ public function getPrincipalByPath($path) { '{DAV:}displayname' => $group->getDisplayName(), ]; } + } elseif ($prefix === 'principals/system') { + return [ + 'uri' => 'principals/system/' . $name, + '{DAV:}displayname' => $this->languageFactory->get('dav')->t("Accounts"), + ]; } return null; } diff --git a/apps/dav/tests/unit/CardDAV/AddressBookTest.php b/apps/dav/tests/unit/CardDAV/AddressBookTest.php index 9aa7eb14fff13..06d81662a4293 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookTest.php @@ -124,7 +124,6 @@ public function testPropPatchNotShared(): void { $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,