From 504f396d33bf454493f39989ff4d89176876250f 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 b0fb8c8ee5c..468961b958e 100644 --- a/apps/dav/lib/CardDAV/AddressBook.php +++ b/apps/dav/lib/CardDAV/AddressBook.php @@ -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); } } diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 045ad4d1385..d7bad8d74ca 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -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; } diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index 0a882288314..b1f1da6f63d 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -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; } diff --git a/apps/dav/tests/unit/CardDAV/AddressBookTest.php b/apps/dav/tests/unit/CardDAV/AddressBookTest.php index 9aa7eb14fff..06d81662a42 100644 --- a/apps/dav/tests/unit/CardDAV/AddressBookTest.php +++ b/apps/dav/tests/unit/CardDAV/AddressBookTest.php @@ -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, -- 2.39.5