feat: delete recent contact

Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
pull/55247/head
SebastianKrupinski 2 weeks ago
parent 47ced2b6a7
commit bb7813095f
  1. 13
      apps/contactsinteraction/lib/AddressBook.php
  2. 13
      apps/contactsinteraction/lib/Card.php

@ -57,12 +57,12 @@ class AddressBook extends ExternalAddressBook implements IACL {
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 @@ class AddressBook extends ExternalAddressBook implements IACL {
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 @@ class AddressBook extends ExternalAddressBook implements IACL {
'principal' => $this->getOwner(),
'protected' => true,
],
[
'privilege' => '{DAV:}unbind',
'principal' => $this->getOwner(),
'protected' => true,
],
];
}

@ -9,6 +9,7 @@ declare(strict_types=1);
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 @@ class Card implements ICard, IACL {
* @inheritDoc
*/
public function getACL(): array {
return $this->acls;
return [
[
'privilege' => '{DAV:}read',
'principal' => $this->getOwner(),
'protected' => true,
],
];
}
/**
@ -84,7 +91,7 @@ class Card implements ICard, IACL {
* @inheritDoc
*/
public function delete(): void {
throw new NotImplemented();
$this->mapper->delete($this->contact);
}
/**

Loading…
Cancel
Save