summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/Sabre
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-04-07 09:18:15 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-04-11 11:56:06 +0200
commit441aab68a4bbc1e2b88831ccb0f885cd80b7dd1a (patch)
tree53fdda07351bae726c5b3461b915ea067aea8351 /apps/files_trashbin/lib/Sabre
parente3f575ba7a600971278a68eeedd123ae8afcd4b8 (diff)
downloadnextcloud-server-441aab68a4bbc1e2b88831ccb0f885cd80b7dd1a.tar.gz
nextcloud-server-441aab68a4bbc1e2b88831ccb0f885cd80b7dd1a.zip
fix(files_trashbin): set real filename on trashbin download
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_trashbin/lib/Sabre')
-rw-r--r--apps/files_trashbin/lib/Sabre/TrashbinPlugin.php (renamed from apps/files_trashbin/lib/Sabre/PropfindPlugin.php)23
1 files changed, 20 insertions, 3 deletions
diff --git a/apps/files_trashbin/lib/Sabre/PropfindPlugin.php b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php
index 219f236f93c..0c3ccee2590 100644
--- a/apps/files_trashbin/lib/Sabre/PropfindPlugin.php
+++ b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php
@@ -27,14 +27,16 @@ declare(strict_types=1);
*/
namespace OCA\Files_Trashbin\Sabre;
-use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCP\IPreview;
use Sabre\DAV\INode;
-use Sabre\DAV\PropFind;
use Sabre\DAV\Server;
+use Sabre\DAV\PropFind;
use Sabre\DAV\ServerPlugin;
+use Sabre\HTTP\RequestInterface;
+use Sabre\HTTP\ResponseInterface;
+use OCA\DAV\Connector\Sabre\FilesPlugin;
-class PropfindPlugin extends ServerPlugin {
+class TrashbinPlugin extends ServerPlugin {
public const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename';
public const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location';
public const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time';
@@ -56,6 +58,7 @@ class PropfindPlugin extends ServerPlugin {
$this->server = $server;
$this->server->on('propFind', [$this, 'propFind']);
+ $this->server->on('afterMethod:GET', [$this,'httpGet']);
}
@@ -110,4 +113,18 @@ class PropfindPlugin extends ServerPlugin {
return '';
});
}
+
+ /**
+ * Set real filename on trashbin download
+ *
+ * @param RequestInterface $request
+ * @param ResponseInterface $response
+ */
+ public function httpGet(RequestInterface $request, ResponseInterface $response): void {
+ $path = $request->getPath();
+ $node = $this->server->tree->getNodeForPath($path);
+ if ($node instanceof ITrash) {
+ $response->addHeader('Content-Disposition', 'attachment; filename="' . $node->getFilename() . '"');
+ }
+ }
}