Skip to content

Commit

Permalink
Merge pull request #27343 from nextcloud/fix/deleted-objects-deletion…
Browse files Browse the repository at this point in the history
…-missing-acls

Add missing ACLs for deleted calendar objects to fix deletion
  • Loading branch information
ChristophWurst authored Jun 2, 2021
2 parents 6578a93 + fc8daf5 commit ac4ff6c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
36 changes: 34 additions & 2 deletions apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,41 @@
use OCA\DAV\CalDAV\IRestorable;
use Sabre\CalDAV\ICalendarObject;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAVACL\ACLTrait;
use Sabre\DAVACL\IACL;

class DeletedCalendarObject implements ICalendarObject, IRestorable {
class DeletedCalendarObject implements IACL, ICalendarObject, IRestorable {
use ACLTrait;

/** @var string */
private $name;

/** @var mixed[] */
private $objectData;

/** @var string */
private $principalUri;

/** @var CalDavBackend */
private $calDavBackend;

public function __construct(string $name,
array $objectData,
string $principalUri,
CalDavBackend $calDavBackend) {
$this->name = $name;
$this->objectData = $objectData;
$this->calDavBackend = $calDavBackend;
$this->principalUri = $principalUri;
}

public function delete() {
throw new Forbidden();
$this->calDavBackend->deleteCalendarObject(
$this->objectData['calendarid'],
$this->objectData['uri'],
CalDavBackend::CALENDAR_TYPE_CALENDAR,
true
);
}

public function getName() {
Expand Down Expand Up @@ -101,4 +114,23 @@ public function getDeletedAt(): ?int {
public function getCalendarUri(): string {
return $this->objectData['calendaruri'];
}

public function getACL(): array {
return [
[
'privilege' => '{DAV:}read', // For queries
'principal' => $this->getOwner(),
'protected' => true,
],
[
'privilege' => '{DAV:}unbind', // For moving and deletion
'principal' => '{DAV:}owner',
'protected' => true,
],
];
}

public function getOwner() {
return $this->principalUri;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function getChild($name) {
return new DeletedCalendarObject(
$this->getRelativeObjectPath($data),
$data,
$this->principalInfo['uri'],
$this->caldavBackend
);
}
Expand Down Expand Up @@ -117,8 +118,8 @@ public function getLastModified(): int {
}

public function calendarQuery(array $filters) {
return array_map(function (array $calendarInfo) {
return $this->getRelativeObjectPath($calendarInfo);
return array_map(function (array $calendarObjectInfo) {
return $this->getRelativeObjectPath($calendarObjectInfo);
}, $this->caldavBackend->getDeletedCalendarObjectsByPrincipal($this->principalInfo['uri']));
}

Expand Down

0 comments on commit ac4ff6c

Please sign in to comment.