Skip to content

Commit 30a9303

Browse files
miaulalalaJohannesGGE
authored andcommitted
fix(CardDAV): set owner-principal, displayname properties for SAB
Signed-off-by: Anna Larch <anna@nextcloud.com>
1 parent e232cd8 commit 30a9303

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

apps/dav/lib/CardDAV/AddressBook.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ public function delete() {
223223
}
224224

225225
public function propPatch(PropPatch $propPatch) {
226-
// shared address books will be handled by
227-
// \OCA\DAV\DAV\CustomPropertiesBackend::propPatch
228-
// to save values in db table instead of dav object
229-
if (!$this->isShared()) {
226+
if (!isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
230227
parent::propPatch($propPatch);
231228
}
232229
}

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,12 @@ public function getAddressBooksByUri(string $principal, string $addressBookUri):
311311
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
312312
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
313313
'{http://sabredav.org/ns}sync-token' => $row['synctoken'] ?: '0',
314+
314315
];
315316

316317
// system address books are always read only
317318
if ($principal === 'principals/system/system') {
319+
$addressBook['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'] = $row['principaluri'];
318320
$addressBook['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'] = true;
319321
}
320322

apps/dav/lib/Connector/Sabre/Principal.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ public function getPrincipalByPath($path) {
208208
'{DAV:}displayname' => $group->getDisplayName(),
209209
];
210210
}
211+
} elseif ($prefix === 'principals/system') {
212+
return [
213+
'uri' => 'principals/system/' . $name,
214+
'{DAV:}displayname' => $this->languageFactory->get('dav')->t("Accounts"),
215+
];
211216
}
212217
return null;
213218
}

apps/dav/tests/unit/CardDAV/AddressBookTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public function testPropPatchNotShared(): void {
124124
$backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
125125
$backend->expects($this->atLeast(1))->method('updateAddressBook');
126126
$addressBookInfo = [
127-
'{http://owncloud.org/ns}owner-principal' => 'user1',
128127
'{DAV:}displayname' => 'Test address book',
129128
'principaluri' => 'user1',
130129
'id' => 666,

0 commit comments

Comments
 (0)