Skip to content

Commit 4e57136

Browse files
authored
Merge pull request #55247 from nextcloud/fix/issue-55169-delete-recent-contact
feat: delete recent contact
2 parents 47ced2b + bb78130 commit 4e57136

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

apps/contactsinteraction/lib/AddressBook.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public function createFile($name, $data = null) {
5757
public function getChild($name): Card {
5858
try {
5959
return new Card(
60+
$this->mapper,
6061
$this->mapper->find(
6162
$this->getUid(),
6263
(int)$name
6364
),
64-
$this->principalUri,
65-
$this->getACL()
65+
$this->principalUri
6666
);
6767
} catch (DoesNotExistException $ex) {
6868
throw new NotFound('Contact does not exist: ' . $ex->getMessage(), 0, $ex);
@@ -76,9 +76,9 @@ public function getChildren(): array {
7676
return array_map(
7777
function (RecentContact $contact) {
7878
return new Card(
79+
$this->mapper,
7980
$contact,
80-
$this->principalUri,
81-
$this->getACL()
81+
$this->principalUri
8282
);
8383
},
8484
$this->mapper->findAll($this->getUid())
@@ -141,6 +141,11 @@ public function getACL(): array {
141141
'principal' => $this->getOwner(),
142142
'protected' => true,
143143
],
144+
[
145+
'privilege' => '{DAV:}unbind',
146+
'principal' => $this->getOwner(),
147+
'protected' => true,
148+
],
144149
];
145150
}
146151

apps/contactsinteraction/lib/Card.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\ContactsInteraction;
1010

1111
use OCA\ContactsInteraction\Db\RecentContact;
12+
use OCA\ContactsInteraction\Db\RecentContactMapper;
1213
use Sabre\CardDAV\ICard;
1314
use Sabre\DAV\Exception\NotImplemented;
1415
use Sabre\DAVACL\ACLTrait;
@@ -18,9 +19,9 @@ class Card implements ICard, IACL {
1819
use ACLTrait;
1920

2021
public function __construct(
22+
private RecentContactMapper $mapper,
2123
private RecentContact $contact,
2224
private string $principal,
23-
private array $acls,
2425
) {
2526
}
2627

@@ -35,7 +36,13 @@ public function getOwner(): ?string {
3536
* @inheritDoc
3637
*/
3738
public function getACL(): array {
38-
return $this->acls;
39+
return [
40+
[
41+
'privilege' => '{DAV:}read',
42+
'principal' => $this->getOwner(),
43+
'protected' => true,
44+
],
45+
];
3946
}
4047

4148
/**
@@ -84,7 +91,7 @@ public function getSize(): int {
8491
* @inheritDoc
8592
*/
8693
public function delete(): void {
87-
throw new NotImplemented();
94+
$this->mapper->delete($this->contact);
8895
}
8996

9097
/**

0 commit comments

Comments
 (0)