]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(CardDAV): set owner-principal, displayname properties for SAB 39525/head
authorAnna Larch <anna@nextcloud.com>
Fri, 21 Jul 2023 10:33:00 +0000 (12:33 +0200)
committerAnna <anna@nextcloud.com>
Wed, 16 Aug 2023 07:11:01 +0000 (09:11 +0200)
Signed-off-by: Anna Larch <anna@nextcloud.com>
apps/dav/lib/CardDAV/AddressBook.php
apps/dav/lib/CardDAV/CardDavBackend.php
apps/dav/lib/Connector/Sabre/Principal.php
apps/dav/tests/unit/CardDAV/AddressBookTest.php

index b0fb8c8ee5c4b1bc17584cd76a9aeda558448c51..468961b958e7168bfdee811f216d991ae2b6989e 100644 (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);
                }
        }
index 045ad4d1385ba1d4b8feccc1662071d8e4c9b336..d7bad8d74cadfad7f3d7ce70df51a7d0605f9ec1 100644 (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;
                }
 
index 0a88228831421f2932b46a379df9c20cd3a5bf2e..b1f1da6f63df4f8af36ea01b8287e09b7afacbb1 100644 (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;
        }
index 9aa7eb14fff13dcbb2248c6af1c43daae1c6fe03..06d81662a4293a71adb6211767593c62423b51b6 100644 (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,