aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2023-06-29 11:00:25 +0200
committerLouis Chemineau <louis@chmn.me>2023-06-29 12:08:59 +0200
commit05acd916b544352ace073dc87ea0556e363f528d (patch)
tree9212d28a2c92de4ed6f1c4ed1f60a15fc2c9033e /apps/files_versions/lib
parent505a11b3e7221d44dd9c850fa1a883930d41dd27 (diff)
downloadnextcloud-server-05acd916b544352ace073dc87ea0556e363f528d.tar.gz
nextcloud-server-05acd916b544352ace073dc87ea0556e363f528d.zip
Base versions' has-preview on mimetype
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/files_versions/lib')
-rw-r--r--apps/files_versions/lib/Sabre/Plugin.php25
-rw-r--r--apps/files_versions/lib/Sabre/VersionFile.php4
2 files changed, 3 insertions, 26 deletions
diff --git a/apps/files_versions/lib/Sabre/Plugin.php b/apps/files_versions/lib/Sabre/Plugin.php
index b53f21039be..5aa64c812c6 100644
--- a/apps/files_versions/lib/Sabre/Plugin.php
+++ b/apps/files_versions/lib/Sabre/Plugin.php
@@ -28,10 +28,8 @@ namespace OCA\Files_Versions\Sabre;
use OC\AppFramework\Http\Request;
use OCA\DAV\Connector\Sabre\FilesPlugin;
-use OCA\Files_Versions\Versions\IVersionManager;
-use OCP\Files\NotFoundException;
+use OCP\IPreview;
use OCP\IRequest;
-use OCP\IUserSession;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;
use Sabre\DAV\PropFind;
@@ -48,8 +46,7 @@ class Plugin extends ServerPlugin {
public function __construct(
private IRequest $request,
- private IVersionManager $versionManager,
- private IUserSession $userSession,
+ private IPreview $previewManager,
) {
$this->request = $request;
}
@@ -94,25 +91,9 @@ class Plugin extends ServerPlugin {
}
public function propFind(PropFind $propFind, INode $node): void {
- $user = $this->userSession->getUser();
-
if ($node instanceof VersionFile) {
$propFind->handle(self::VERSION_LABEL, fn() => $node->getLabel());
-
- if ($user !== null) {
- $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, function () use ($node, $user) {
- try {
- $this->versionManager->getVersionFile(
- $user,
- $node->getSourceFile(),
- $node->getVersion()->getRevisionId()
- );
- return true;
- } catch (NotFoundException $ex) {
- return false;
- }
- });
- }
+ $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, fn () => $this->previewManager->isMimeSupported($node->getContentType()));
}
}
diff --git a/apps/files_versions/lib/Sabre/VersionFile.php b/apps/files_versions/lib/Sabre/VersionFile.php
index bb05d66460a..a03ecd64b46 100644
--- a/apps/files_versions/lib/Sabre/VersionFile.php
+++ b/apps/files_versions/lib/Sabre/VersionFile.php
@@ -61,10 +61,6 @@ class VersionFile implements IFile {
}
}
- public function getSourceFile(): FileInfo {
- return $this->version->getSourceFile();
- }
-
public function getContentType(): string {
return $this->version->getMimeType();
}