Skip to content

Commit

Permalink
fix(CardDAV): set owner-principal, displayname properties for SAB
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Larch <[email protected]>
  • Loading branch information
miaulalala committed Aug 16, 2023
1 parent 091c1ed commit 6bd7891
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions apps/dav/lib/CardDAV/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 2 additions & 0 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions apps/dav/lib/Connector/Sabre/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion apps/dav/tests/unit/CardDAV/AddressBookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6bd7891

Please sign in to comment.