From 21d4ce926ef980db40fc1260ea3686be01a81252 Mon Sep 17 00:00:00 2001
From: Roeland Jago Douma <roeland@famdouma.nl>
Date: Tue, 8 May 2018 09:08:43 +0200
Subject: [PATCH] Propfind for deletion time of trash files

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
---
 apps/files_trashbin/lib/Sabre/ITrash.php            | 2 ++
 apps/files_trashbin/lib/Sabre/PropfindPlugin.php    | 5 +++++
 apps/files_trashbin/lib/Sabre/TrashFile.php         | 4 +++-
 apps/files_trashbin/lib/Sabre/TrashFolder.php       | 3 +++
 apps/files_trashbin/lib/Sabre/TrashFolderFile.php   | 4 +++-
 apps/files_trashbin/lib/Sabre/TrashFolderFolder.php | 4 +++-
 6 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/apps/files_trashbin/lib/Sabre/ITrash.php b/apps/files_trashbin/lib/Sabre/ITrash.php
index b0ff2b1570a..7ec27f78859 100644
--- a/apps/files_trashbin/lib/Sabre/ITrash.php
+++ b/apps/files_trashbin/lib/Sabre/ITrash.php
@@ -29,4 +29,6 @@ interface ITrash {
 	public function getFilename(): string;
 
 	public function getOriginalLocation(): string;
+
+	public function getDeletionTime(): int;
 }
diff --git a/apps/files_trashbin/lib/Sabre/PropfindPlugin.php b/apps/files_trashbin/lib/Sabre/PropfindPlugin.php
index e50ee08590a..a0aaa552a14 100644
--- a/apps/files_trashbin/lib/Sabre/PropfindPlugin.php
+++ b/apps/files_trashbin/lib/Sabre/PropfindPlugin.php
@@ -33,6 +33,7 @@ class PropfindPlugin extends ServerPlugin {
 
 	const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename';
 	const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location';
+	const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time';
 
 	/** @var Server */
 	private $server;
@@ -59,6 +60,10 @@ class PropfindPlugin extends ServerPlugin {
 		$propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function() use ($node) {
 			return $node->getOriginalLocation();
 		});
+
+		$propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) {
+			return $node->getDeletionTime();
+		});
 	}
 
 }
diff --git a/apps/files_trashbin/lib/Sabre/TrashFile.php b/apps/files_trashbin/lib/Sabre/TrashFile.php
index 29e7a955623..e4c67cbfb31 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFile.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFile.php
@@ -87,5 +87,7 @@ class TrashFile implements IFile, ITrash {
 		return $this->data['extraData'];
 	}
 
-
+	public function getDeletionTime(): int {
+		return $this->getLastModified();
+	}
 }
diff --git a/apps/files_trashbin/lib/Sabre/TrashFolder.php b/apps/files_trashbin/lib/Sabre/TrashFolder.php
index 33236eea262..e1fd965487b 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFolder.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFolder.php
@@ -116,5 +116,8 @@ class TrashFolder implements ICollection, ITrash {
 		return $this->data['extraData'];
 	}
 
+	public function getDeletionTime(): int {
+		return $this->getLastModified();
+	}
 
 }
diff --git a/apps/files_trashbin/lib/Sabre/TrashFolderFile.php b/apps/files_trashbin/lib/Sabre/TrashFolderFile.php
index 95e82d95a6e..9dd2f7b3ef5 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFolderFile.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFolderFile.php
@@ -98,5 +98,7 @@ class TrashFolderFile implements IFile, ITrash {
 		return $this->location . '/' . $this->getFilename();
 	}
 
-
+	public function getDeletionTime(): int {
+		return $this->getLastModified();
+	}
 }
diff --git a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php
index d2923c58916..3c2c4138095 100644
--- a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php
+++ b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php
@@ -129,5 +129,7 @@ class TrashFolderFolder implements ICollection, ITrash {
 		return $this->location . '/' . $this->getFilename();
 	}
 
-
+	public function getDeletionTime(): int {
+		return $this->getLastModified();
+	}
 }
-- 
GitLab