2424
2525namespace OCA \Activity \Controller ;
2626
27- use OC \Files \View ;
2827use OCA \Activity \Data ;
2928use OCA \Activity \Exception \InvalidFilterException ;
3029use OCA \Activity \GroupHelper ;
@@ -93,28 +92,9 @@ class APIv2Controller extends OCSController {
9392 /** @var IMimeTypeDetector */
9493 protected $ mimeTypeDetector ;
9594
96- /** @var View */
97- protected $ view ;
98-
9995 /** @var ViewInfoCache */
10096 protected $ infoCache ;
10197
102- /**
103- * OCSEndPoint constructor.
104- *
105- * @param string $appName
106- * @param IRequest $request
107- * @param IManager $activityManager
108- * @param Data $data
109- * @param GroupHelper $helper
110- * @param UserSettings $settings
111- * @param IURLGenerator $urlGenerator
112- * @param IUserSession $userSession
113- * @param IPreview $preview
114- * @param IMimeTypeDetector $mimeTypeDetector
115- * @param View $view
116- * @param ViewInfoCache $infoCache
117- */
11898 public function __construct ($ appName ,
11999 IRequest $ request ,
120100 IManager $ activityManager ,
@@ -125,7 +105,6 @@ public function __construct($appName,
125105 IUserSession $ userSession ,
126106 IPreview $ preview ,
127107 IMimeTypeDetector $ mimeTypeDetector ,
128- View $ view ,
129108 ViewInfoCache $ infoCache ) {
130109 parent ::__construct ($ appName , $ request );
131110 $ this ->activityManager = $ activityManager ;
@@ -136,7 +115,6 @@ public function __construct($appName,
136115 $ this ->userSession = $ userSession ;
137116 $ this ->preview = $ preview ;
138117 $ this ->mimeTypeDetector = $ mimeTypeDetector ;
139- $ this ->view = $ view ;
140118 $ this ->infoCache = $ infoCache ;
141119 }
142120
@@ -357,7 +335,7 @@ protected function getPreview(string $owner, int $fileId, string $filePath): arr
357335 }
358336
359337 $ preview = [
360- 'link ' => $ this ->getPreviewLink ( $ info [ ' path ' ], $ info [ ' is_dir ' ], $ info [ ' view ' ]),
338+ 'link ' => $ this ->urlGenerator -> linkToRouteAbsolute ( ' files.viewcontroller.showFile ' , [ ' fileid ' => $ fileId ]),
361339 'source ' => '' ,
362340 'mimeType ' => 'application/octet-stream ' ,
363341 'isMimeTypeIcon ' => true ,
@@ -371,8 +349,7 @@ protected function getPreview(string $owner, int $fileId, string $filePath): arr
371349 $ preview ['source ' ] = $ this ->getPreviewPathFromMimeType ('dir ' );
372350 $ preview ['mimeType ' ] = 'dir ' ;
373351 } else {
374- $ this ->view ->chroot ('/ ' . $ owner . '/files ' );
375- $ fileInfo = $ this ->view ->getFileInfo ($ info ['path ' ]);
352+ $ fileInfo = $ info ['node ' ] ?? null ;
376353 if (!($ fileInfo instanceof FileInfo)) {
377354 $ preview = $ this ->getPreviewFromPath ($ fileId , $ filePath , $ info );
378355 } elseif ($ this ->preview ->isAvailable ($ fileInfo )) {
@@ -382,7 +359,7 @@ protected function getPreview(string $owner, int $fileId, string $filePath): arr
382359 'x ' => 250 ,
383360 'y ' => 250 ,
384361 'fileId ' => $ fileId ,
385- 'c ' => $ fileInfo ->getEtag ()
362+ 'c ' => $ fileInfo ->getEtag (),
386363 ];
387364
388365 $ preview ['source ' ] = $ this ->urlGenerator ->linkToRouteAbsolute ('core.Preview.getPreviewByFileId ' , $ params );
@@ -400,7 +377,7 @@ protected function getPreview(string $owner, int $fileId, string $filePath): arr
400377 protected function getPreviewFromPath (int $ fileId , string $ filePath , array $ info ): array {
401378 $ mimeType = $ info ['is_dir ' ] ? 'dir ' : $ this ->mimeTypeDetector ->detectPath ($ filePath );
402379 return [
403- 'link ' => $ this ->getPreviewLink ( $ info [ ' path ' ], $ info [ ' is_dir ' ], $ info [ ' view ' ]),
380+ 'link ' => $ this ->urlGenerator -> linkToRouteAbsolute ( ' files.viewcontroller.showFile ' , [ ' fileid ' => $ fileId ]),
404381 'source ' => $ this ->getPreviewPathFromMimeType ($ mimeType ),
405382 'mimeType ' => $ mimeType ,
406383 'isMimeTypeIcon ' => true ,
@@ -418,18 +395,4 @@ protected function getPreviewPathFromMimeType(string $mimeType): string {
418395
419396 return $ this ->urlGenerator ->getAbsoluteURL ($ mimeTypeIcon );
420397 }
421-
422- protected function getPreviewLink (string $ path , bool $ isDir , string $ view ): string {
423- $ params = [
424- 'dir ' => $ path ,
425- ];
426- if (!$ isDir ) {
427- $ params ['dir ' ] = (substr_count ($ path , '/ ' ) === 1 ) ? '/ ' : \dirname ($ path );
428- $ params ['scrollto ' ] = basename ($ path );
429- }
430- if ($ view !== '' ) {
431- $ params ['view ' ] = $ view ;
432- }
433- return $ this ->urlGenerator ->linkToRouteAbsolute ('files.view.index ' , $ params );
434- }
435398}
0 commit comments