diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-05-31 18:24:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-31 18:24:30 +0200 |
commit | b908db7ac88a37fa5d9e98ae5ab570fac1b70063 (patch) | |
tree | 1b4d5f4ec8c828c9bc8edaec3760b84cba5134ec /apps/dav | |
parent | 7e8ddcd38f2bbd10040275566b0195baad2cfc8f (diff) | |
parent | fe31373a93b99a1ee61584f7394c7a912ca04e90 (diff) | |
download | nextcloud-server-b908db7ac88a37fa5d9e98ae5ab570fac1b70063.tar.gz nextcloud-server-b908db7ac88a37fa5d9e98ae5ab570fac1b70063.zip |
Merge pull request #27298 from nextcloud/fix/caldav-deleted-objects-expose-timestamp
Expose deletion timestamp for deleted CalDAV objects
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php | 4 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Trashbin/Plugin.php | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php b/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php index 43d96b52efd..0517125ef48 100644 --- a/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php +++ b/apps/dav/lib/CalDAV/Trashbin/DeletedCalendarObject.php @@ -93,4 +93,8 @@ class DeletedCalendarObject implements ICalendarObject, IRestorable { public function restore(): void { $this->calDavBackend->restoreCalendarObject($this->objectData); } + + public function getDeletedAt(): ?int { + return $this->objectData['deleted_at'] ? (int) $this->objectData['deleted_at'] : null; + } } diff --git a/apps/dav/lib/CalDAV/Trashbin/Plugin.php b/apps/dav/lib/CalDAV/Trashbin/Plugin.php index d42a09f1c0d..7fd127479c5 100644 --- a/apps/dav/lib/CalDAV/Trashbin/Plugin.php +++ b/apps/dav/lib/CalDAV/Trashbin/Plugin.php @@ -25,9 +25,12 @@ declare(strict_types=1); namespace OCA\DAV\CalDAV\Trashbin; +use Closure; use OCA\DAV\CalDAV\Calendar; use OCP\IRequest; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\INode; +use Sabre\DAV\PropFind; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; use Sabre\HTTP\RequestInterface; @@ -35,10 +38,8 @@ use Sabre\HTTP\ResponseInterface; use function array_slice; use function implode; -/** - * Conditional logic to bypass the calendar trashbin - */ class Plugin extends ServerPlugin { + public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at'; /** @var bool */ private $disableTrashbin; @@ -53,6 +54,7 @@ class Plugin extends ServerPlugin { public function initialize(Server $server): void { $this->server = $server; $server->on('beforeMethod:*', [$this, 'beforeMethod']); + $server->on('propFind', Closure::fromCallable([$this, 'propFind'])); } public function beforeMethod(RequestInterface $request, ResponseInterface $response): void { @@ -86,6 +88,16 @@ class Plugin extends ServerPlugin { } } + private function propFind( + PropFind $propFind, + INode $node): void { + if ($node instanceof DeletedCalendarObject) { + $propFind->handle(self::PROPERTY_DELETED_AT, function () use ($node) { + return $node->getDeletedAt(); + }); + } + } + public function getFeatures(): array { return ['nc-calendar-trashbin']; } |