Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2021-06-03 11:48:35 +0300
committerGitHub <noreply@github.com>2021-06-03 11:48:35 +0300
commit188bc078693a160d44283e735268b38c3042d7a5 (patch)
treeb4e46f15eb1f4c5bd293f1877a675d0ca005f199
parent26f537fbec1e2fb388823a56c8153cebb8c7e4b7 (diff)
parentf1444eac5d6cf64f0700732b47f53919e9ff7c1a (diff)
Merge pull request #27348 from nextcloud/enhancement/calendar-trashbin-retention-prop
Export the CalDAV trash bin retention duration as property
-rw-r--r--apps/dav/lib/CalDAV/RetentionService.php8
-rw-r--r--apps/dav/lib/CalDAV/Trashbin/Plugin.php14
-rw-r--r--apps/dav/lib/Server.php2
3 files changed, 20 insertions, 4 deletions
diff --git a/apps/dav/lib/CalDAV/RetentionService.php b/apps/dav/lib/CalDAV/RetentionService.php
index 934e6f71530..7342b719c81 100644
--- a/apps/dav/lib/CalDAV/RetentionService.php
+++ b/apps/dav/lib/CalDAV/RetentionService.php
@@ -51,8 +51,8 @@ class RetentionService {
$this->calDavBackend = $calDavBackend;
}
- public function cleanUp(): void {
- $retentionTime = max(
+ public function getDuration(): int {
+ return max(
(int) $this->config->getAppValue(
Application::APP_ID,
self::RETENTION_CONFIG_KEY,
@@ -60,6 +60,10 @@ class RetentionService {
),
0 // Just making sure we don't delete things in the future when a negative number is passed
);
+ }
+
+ public function cleanUp(): void {
+ $retentionTime = $this->getDuration();
$now = $this->time->getTime();
$calendars = $this->calDavBackend->getDeletedCalendars($now - $retentionTime);
diff --git a/apps/dav/lib/CalDAV/Trashbin/Plugin.php b/apps/dav/lib/CalDAV/Trashbin/Plugin.php
index fd47e1faa30..93f17cc5b7c 100644
--- a/apps/dav/lib/CalDAV/Trashbin/Plugin.php
+++ b/apps/dav/lib/CalDAV/Trashbin/Plugin.php
@@ -27,6 +27,7 @@ namespace OCA\DAV\CalDAV\Trashbin;
use Closure;
use OCA\DAV\CalDAV\Calendar;
+use OCA\DAV\CalDAV\RetentionService;
use OCP\IRequest;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;
@@ -41,15 +42,21 @@ use function implode;
class Plugin extends ServerPlugin {
public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at';
public const PROPERTY_CALENDAR_URI = '{http://nextcloud.com/ns}calendar-uri';
+ public const PROPERTY_RETENTION_DURATION = '{http://nextcloud.com/ns}trash-bin-retention-duration';
/** @var bool */
private $disableTrashbin;
+ /** @var RetentionService */
+ private $retentionService;
+
/** @var Server */
private $server;
- public function __construct(IRequest $request) {
+ public function __construct(IRequest $request,
+ RetentionService $retentionService) {
$this->disableTrashbin = $request->getHeader('X-NC-CalDAV-No-Trashbin') === '1';
+ $this->retentionService = $retentionService;
}
public function initialize(Server $server): void {
@@ -100,6 +107,11 @@ class Plugin extends ServerPlugin {
return $node->getCalendarUri();
});
}
+ if ($node instanceof TrashbinHome) {
+ $propFind->handle(self::PROPERTY_RETENTION_DURATION, function () use ($node) {
+ return $this->retentionService->getDuration();
+ });
+ }
}
public function getFeatures(): array {
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php
index 0999da3dbe1..50c64380184 100644
--- a/apps/dav/lib/Server.php
+++ b/apps/dav/lib/Server.php
@@ -165,7 +165,7 @@ class Server {
$this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
}
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Trashbin\Plugin($request));
+ $this->server->addPlugin(\OC::$server->get(\OCA\DAV\CalDAV\Trashbin\Plugin::class));
$this->server->addPlugin(new \OCA\DAV\CalDAV\WebcalCaching\Plugin($request));
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());