Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions apps/contactsinteraction/lib/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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())
Expand Down Expand Up @@ -141,6 +141,11 @@ public function getACL(): array {
'principal' => $this->getOwner(),
'protected' => true,
],
[
'privilege' => '{DAV:}unbind',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my understanding, why is the unbind ACL granted for the collection but not the card? doesn't that mean the collection is allowed to be deleted? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought the same thing at first the ACL's should technically be on the Object, not the collection, but SabreDAV ignores the ACL on the Object. (Dose not send them) So in the context of Address books, unbind on the collection means "Delete an object", I'm guessing this is because it's a flat list instead of a collection/object tree. I can look more in to it, if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

'principal' => $this->getOwner(),
'protected' => true,
],
];
}

Expand Down
13 changes: 10 additions & 3 deletions apps/contactsinteraction/lib/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
) {
}

Expand All @@ -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,
],
];
}

/**
Expand Down Expand Up @@ -84,7 +91,7 @@ public function getSize(): int {
* @inheritDoc
*/
public function delete(): void {
throw new NotImplemented();
$this->mapper->delete($this->contact);
}

/**
Expand Down
Loading