File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -51,15 +51,19 @@ public function __construct(IConfig $config,
5151 $ this ->calDavBackend = $ calDavBackend ;
5252 }
5353
54- public function cleanUp (): void {
55- $ retentionTime = max (
54+ public function getDuration (): int {
55+ return max (
5656 (int ) $ this ->config ->getAppValue (
5757 Application::APP_ID ,
5858 self ::RETENTION_CONFIG_KEY ,
5959 (string ) self ::DEFAULT_RETENTION_SECONDS
6060 ),
6161 0 // Just making sure we don't delete things in the future when a negative number is passed
6262 );
63+ }
64+
65+ public function cleanUp (): void {
66+ $ retentionTime = $ this ->getDuration ();
6367 $ now = $ this ->time ->getTime ();
6468
6569 $ calendars = $ this ->calDavBackend ->getDeletedCalendars ($ now - $ retentionTime );
Original file line number Diff line number Diff line change 2727
2828use Closure ;
2929use OCA \DAV \CalDAV \Calendar ;
30+ use OCA \DAV \CalDAV \RetentionService ;
3031use OCP \IRequest ;
3132use Sabre \DAV \Exception \NotFound ;
3233use Sabre \DAV \INode ;
4142class Plugin extends ServerPlugin {
4243 public const PROPERTY_DELETED_AT = '{http://nextcloud.com/ns}deleted-at ' ;
4344 public const PROPERTY_CALENDAR_URI = '{http://nextcloud.com/ns}calendar-uri ' ;
45+ public const PROPERTY_RETENTION_DURATION = '{http://nextcloud.com/ns}caldav-trashbin-retention-duration ' ;
4446
4547 /** @var bool */
4648 private $ disableTrashbin ;
4749
50+ /** @var RetentionService */
51+ private $ retentionService ;
52+
4853 /** @var Server */
4954 private $ server ;
5055
51- public function __construct (IRequest $ request ) {
56+ public function __construct (IRequest $ request ,
57+ RetentionService $ retentionService ) {
5258 $ this ->disableTrashbin = $ request ->getHeader ('X-NC-CalDAV-No-Trashbin ' ) === '1 ' ;
59+ $ this ->retentionService = $ retentionService ;
5360 }
5461
5562 public function initialize (Server $ server ): void {
@@ -100,6 +107,11 @@ private function propFind(
100107 return $ node ->getCalendarUri ();
101108 });
102109 }
110+ if ($ node instanceof TrashbinHome) {
111+ $ propFind ->handle (self ::PROPERTY_RETENTION_DURATION , function () use ($ node ) {
112+ return $ this ->retentionService ->getDuration ();
113+ });
114+ }
103115 }
104116
105117 public function getFeatures (): array {
Original file line number Diff line number Diff line change @@ -165,7 +165,7 @@ public function __construct(IRequest $request, $baseUri) {
165165 $ this ->server ->addPlugin (\OC ::$ server ->query (\OCA \DAV \CalDAV \Schedule \IMipPlugin::class));
166166 }
167167
168- $ this ->server ->addPlugin (new \ OCA \DAV \CalDAV \Trashbin \Plugin ( $ request ));
168+ $ this ->server ->addPlugin (\ OC :: $ server -> get (\ OCA \DAV \CalDAV \Trashbin \Plugin::class ));
169169 $ this ->server ->addPlugin (new \OCA \DAV \CalDAV \WebcalCaching \Plugin ($ request ));
170170 $ this ->server ->addPlugin (new \Sabre \CalDAV \Subscriptions \Plugin ());
171171
You can’t perform that action at this time.
0 commit comments