@@ -627,27 +627,47 @@ private function getSharesInDir(Node $folder): DataResponse {
627
627
/** @var \OCP\Share\IShare[] $shares */
628
628
$ shares = [];
629
629
foreach ($ nodes as $ node ) {
630
- $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_USER , $ node , false , -1 , 0 ));
631
- $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_GROUP , $ node , false , -1 , 0 ));
632
- $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_LINK , $ node , false , -1 , 0 ));
633
- if ($ this ->shareManager ->shareProviderExists (Share::SHARE_TYPE_EMAIL )) {
634
- $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_EMAIL , $ node , false , -1 , 0 ));
630
+
631
+ $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_USER , $ node , true , -1 , 0 ));
632
+ $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_GROUP , $ node , true , -1 , 0 ));
633
+ $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_LINK , $ node , true , -1 , 0 ));
634
+ if ($ this ->shareManager ->shareProviderExists (Share::SHARE_TYPE_EMAIL )) {
635
+ $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_EMAIL , $ node , true , -1 , 0 ));
635
636
}
636
637
if ($ this ->shareManager ->outgoingServer2ServerSharesAllowed ()) {
637
- $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_REMOTE , $ node , false , -1 , 0 ));
638
+ $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_REMOTE , $ node , true , -1 , 0 ));
638
639
}
639
- $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_ROOM , $ node , false , -1 , 0 ));
640
+ $ shares = array_merge ($ shares , $ this ->shareManager ->getSharesBy ($ this ->currentUser , Share::SHARE_TYPE_ROOM , $ node , true , -1 , 0 ));
640
641
}
641
642
642
- $ formatted = [];
643
+ $ formatted = $ miniFormatted = [];
644
+ $ resharingRight = false ;
645
+ $ known = [];
643
646
foreach ($ shares as $ share ) {
647
+ if (in_array ($ share ->getId (), $ known ) || $ share ->getSharedWith () === $ this ->currentUser ) {
648
+ continue ;
649
+ }
650
+
644
651
try {
645
- $ formatted [] = $ this ->formatShare ($ share );
646
- } catch (NotFoundException $ e ) {
652
+ $ format = $ this ->formatShare ($ share );
653
+
654
+ $ known [] = $ share ->getId ();
655
+ $ formatted [] = $ format ;
656
+ if ($ share ->getSharedBy () === $ this ->currentUser ) {
657
+ $ miniFormatted [] = $ format ;
658
+ }
659
+ if (!$ resharingRight && $ this ->shareProviderResharingRights ($ this ->currentUser , $ share , $ folder )) {
660
+ $ resharingRight = true ;
661
+ }
662
+ } catch (\Exception $ e ) {
647
663
//Ignore this share
648
664
}
649
665
}
650
666
667
+ if (!$ resharingRight ) {
668
+ $ formatted = $ miniFormatted ;
669
+ }
670
+
651
671
return new DataResponse ($ formatted );
652
672
}
653
673
0 commit comments