]> source.dussan.org Git - nextcloud-server.git/commitdiff
Base versions' has-preview on mimetype 38905/head
authorLouis Chemineau <louis@chmn.me>
Thu, 29 Jun 2023 09:00:25 +0000 (11:00 +0200)
committerLouis Chemineau <louis@chmn.me>
Thu, 29 Jun 2023 10:08:59 +0000 (12:08 +0200)
Signed-off-by: Louis Chemineau <louis@chmn.me>
apps/files_versions/lib/Sabre/Plugin.php
apps/files_versions/lib/Sabre/VersionFile.php

index b53f21039be167d9bdfcdb101425ecf2a73216bd..5aa64c812c6698d85af0da5af7835e184e8838df 100644 (file)
@@ -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()));
                }
        }
 
index bb05d66460a55f4cbde8095334b650c3ad771742..a03ecd64b46adcc431ebd1ca446022e2782e56f9 100644 (file)
@@ -61,10 +61,6 @@ class VersionFile implements IFile {
                }
        }
 
-       public function getSourceFile(): FileInfo {
-               return $this->version->getSourceFile();
-       }
-
        public function getContentType(): string {
                return $this->version->getMimeType();
        }