2828
2929use OC \AppFramework \Http \Request ;
3030use OCA \DAV \Connector \Sabre \FilesPlugin ;
31- use OCA \Files_Versions \Versions \IVersionManager ;
32- use OCP \Files \NotFoundException ;
31+ use OCP \IPreview ;
3332use OCP \IRequest ;
34- use OCP \IUserSession ;
3533use Sabre \DAV \Exception \NotFound ;
3634use Sabre \DAV \INode ;
3735use Sabre \DAV \PropFind ;
@@ -48,8 +46,7 @@ class Plugin extends ServerPlugin {
4846
4947 public function __construct (
5048 private IRequest $ request ,
51- private IVersionManager $ versionManager ,
52- private IUserSession $ userSession ,
49+ private IPreview $ previewManager ,
5350 ) {
5451 $ this ->request = $ request ;
5552 }
@@ -94,25 +91,9 @@ public function afterGet(RequestInterface $request, ResponseInterface $response)
9491 }
9592
9693 public function propFind (PropFind $ propFind , INode $ node ): void {
97- $ user = $ this ->userSession ->getUser ();
98-
9994 if ($ node instanceof VersionFile) {
10095 $ propFind ->handle (self ::VERSION_LABEL , fn () => $ node ->getLabel ());
101-
102- if ($ user !== null ) {
103- $ propFind ->handle (FilesPlugin::HAS_PREVIEW_PROPERTYNAME , function () use ($ node , $ user ) {
104- try {
105- $ this ->versionManager ->getVersionFile (
106- $ user ,
107- $ node ->getSourceFile (),
108- $ node ->getVersion ()->getRevisionId ()
109- );
110- return true ;
111- } catch (NotFoundException $ ex ) {
112- return false ;
113- }
114- });
115- }
96+ $ propFind ->handle (FilesPlugin::HAS_PREVIEW_PROPERTYNAME , fn () => $ this ->previewManager ->isMimeSupported ($ node ->getContentType ()));
11697 }
11798 }
11899
0 commit comments