Add missing ACLs for deleted calendar objects to fix deletion

Due to a bug in Sabre it's necessary for calendar objects to implement
ACLs. Otherwise the scheduling plugin will throw an error when it tries
to fetch the owner of a calendar object that is being deleted.

Ref https://github.com/sabre-io/dav/issues/1345

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2021-06-02 10:35:46 +02:00
parent d9a9714675
commit fc8daf58ee
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
2 changed files with 37 additions and 4 deletions

View File

@ -29,8 +29,11 @@ use OCA\DAV\CalDAV\CalDavBackend;
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;
@ -38,19 +41,29 @@ class DeletedCalendarObject implements ICalendarObject, IRestorable {
/** @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() {
@ -101,4 +114,23 @@ class DeletedCalendarObject implements ICalendarObject, IRestorable {
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;
}
}

View File

@ -78,6 +78,7 @@ class DeletedCalendarObjectsCollection implements ICalendarObjectContainer {
return new DeletedCalendarObject(
$this->getRelativeObjectPath($data),
$data,
$this->principalInfo['uri'],
$this->caldavBackend
);
}
@ -117,8 +118,8 @@ class DeletedCalendarObjectsCollection implements ICalendarObjectContainer {
}
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']));
}