diff --git a/apps/contactsinteraction/lib/AddressBook.php b/apps/contactsinteraction/lib/AddressBook.php index 60c9eccece38c..601bc3669935b 100644 --- a/apps/contactsinteraction/lib/AddressBook.php +++ b/apps/contactsinteraction/lib/AddressBook.php @@ -57,12 +57,12 @@ public function createFile($name, $data = null) { public function getChild($name): Card { try { return new Card( + $this->mapper, $this->mapper->find( $this->getUid(), (int)$name ), - $this->principalUri, - $this->getACL() + $this->principalUri ); } catch (DoesNotExistException $ex) { throw new NotFound('Contact does not exist: ' . $ex->getMessage(), 0, $ex); @@ -76,9 +76,9 @@ public function getChildren(): array { return array_map( function (RecentContact $contact) { return new Card( + $this->mapper, $contact, - $this->principalUri, - $this->getACL() + $this->principalUri ); }, $this->mapper->findAll($this->getUid()) @@ -141,6 +141,11 @@ public function getACL(): array { 'principal' => $this->getOwner(), 'protected' => true, ], + [ + 'privilege' => '{DAV:}unbind', + 'principal' => $this->getOwner(), + 'protected' => true, + ], ]; } diff --git a/apps/contactsinteraction/lib/Card.php b/apps/contactsinteraction/lib/Card.php index bf0acca7bd5ae..cfd6798ab0652 100644 --- a/apps/contactsinteraction/lib/Card.php +++ b/apps/contactsinteraction/lib/Card.php @@ -9,6 +9,7 @@ namespace OCA\ContactsInteraction; use OCA\ContactsInteraction\Db\RecentContact; +use OCA\ContactsInteraction\Db\RecentContactMapper; use Sabre\CardDAV\ICard; use Sabre\DAV\Exception\NotImplemented; use Sabre\DAVACL\ACLTrait; @@ -18,9 +19,9 @@ class Card implements ICard, IACL { use ACLTrait; public function __construct( + private RecentContactMapper $mapper, private RecentContact $contact, private string $principal, - private array $acls, ) { } @@ -35,7 +36,13 @@ public function getOwner(): ?string { * @inheritDoc */ public function getACL(): array { - return $this->acls; + return [ + [ + 'privilege' => '{DAV:}read', + 'principal' => $this->getOwner(), + 'protected' => true, + ], + ]; } /** @@ -84,7 +91,7 @@ public function getSize(): int { * @inheritDoc */ public function delete(): void { - throw new NotImplemented(); + $this->mapper->delete($this->contact); } /**