1616use OCP \Files \FileInfo ;
1717use OCP \Files \IRootFolder ;
1818use OCP \Files \NotFoundException ;
19+ use OCP \Files \Storage \ISharedStorage ;
1920use OCP \Files \StorageNotAvailableException ;
2021use OCP \Share \Exceptions \ShareNotFound ;
2122use OCP \Share \IManager ;
@@ -262,8 +263,8 @@ public function getSharePermissions($user) {
262263 $ storage = null ;
263264 }
264265
265- if ($ storage && $ storage ->instanceOfStorage (' \OCA\Files_Sharing\SharedStorage ' )) {
266- /** @var \OCA\Files_Sharing\SharedStorage $storage */
266+ if ($ storage && $ storage ->instanceOfStorage (ISharedStorage::class )) {
267+ /** @var ISharedStorage $storage */
267268 $ permissions = (int )$ storage ->getShare ()->getPermissions ();
268269 } else {
269270 $ permissions = $ this ->info ->getPermissions ();
@@ -306,8 +307,8 @@ public function getShareAttributes(): array {
306307 }
307308
308309 $ attributes = [];
309- if (method_exists ( $ storage, ' getShare ' )) {
310- /** @var \OCA\Files_Sharing\SharedStorage $storage */
310+ if ($ storage-> instanceOfStorage (ISharedStorage::class )) {
311+ /** @var ISharedStorage $storage */
311312 $ attributes = $ storage ->getShare ()->getAttributes ();
312313 if ($ attributes === null ) {
313314 return [];
@@ -319,25 +320,24 @@ public function getShareAttributes(): array {
319320 return $ attributes ;
320321 }
321322
322- public function getNoteFromShare (?string $ user ): string {
323+ public function getNoteFromShare (?string $ user ): string | null {
323324 try {
324325 $ storage = $ this ->node ->getStorage ();
325326 } catch (NotFoundException ) {
326- return '' ;
327+ return null ;
327328 }
328329
329- if (!method_exists ($ storage , 'getShare ' )) {
330- return '' ;
330+ if ($ storage ->instanceOfStorage (ISharedStorage::class)) {
331+ /** @var ISharedStorage $storage */
332+ $ share = $ storage ->getShare ();
333+ if ($ user === $ share ->getShareOwner ()) {
334+ // Note is only for recipient not the owner
335+ return null ;
336+ }
337+ return $ share ->getNote ();
331338 }
332- /** @var \OCA\Files_Sharing\SharedStorage $storage */
333339
334- $ share = $ storage ->getShare ();
335- $ note = $ share ->getNote ();
336- if ($ user === $ share ->getShareOwner ()) {
337- // Note is only for recipient not the owner
338- return '' ;
339- }
340- return $ note ;
340+ return null ;
341341 }
342342
343343 /**
0 commit comments