7171use OCP \IUserManager ;
7272use OCP \Lock \ILockingProvider ;
7373use OCP \Lock \LockedException ;
74- use OCP \Share ;
7574use OCP \Share \Exceptions \GenericShareException ;
7675use OCP \Share \Exceptions \ShareNotFound ;
7776use OCP \Share \IManager ;
@@ -523,7 +522,7 @@ public function createShare(
523522 $ share ->setSharedWith ($ shareWith );
524523 $ share ->setPermissions ($ permissions );
525524 } elseif ($ shareType === IShare::TYPE_LINK
526- || $ shareType === IShare::TYPE_EMAIL ) {
525+ || $ shareType === IShare::TYPE_EMAIL ) {
527526
528527 // Can we even share links?
529528 if (!$ this ->shareManager ->shareApiAllowLinks ()) {
@@ -542,9 +541,9 @@ public function createShare(
542541 }
543542
544543 $ permissions = Constants::PERMISSION_READ |
545- Constants::PERMISSION_CREATE |
546- Constants::PERMISSION_UPDATE |
547- Constants::PERMISSION_DELETE ;
544+ Constants::PERMISSION_CREATE |
545+ Constants::PERMISSION_UPDATE |
546+ Constants::PERMISSION_DELETE ;
548547 } else {
549548 $ permissions = Constants::PERMISSION_READ ;
550549 }
@@ -1234,17 +1233,17 @@ public function pendingShares(): DataResponse {
12341233 $ userFolder = $ this ->rootFolder ->getUserFolder ($ share ->getSharedBy ());
12351234 $ nodes = $ userFolder ->getById ($ share ->getNodeId ());
12361235 if (empty ($ nodes )) {
1237- // fallback to guessing the path
1238- $ node = $ userFolder ->get ($ share ->getTarget ());
1239- if ($ node === null || $ share ->getTarget () === '' ) {
1240- return null ;
1236+ // fallback to guessing the path
1237+ $ node = $ userFolder ->get ($ share ->getTarget ());
1238+ if ($ node === null || $ share ->getTarget () === '' ) {
1239+ return null ;
1240+ }
1241+ } else {
1242+ $ node = $ nodes [0 ];
12411243 }
1242- } else {
1243- $ node = $ nodes [0 ];
1244- }
12451244
1246- try {
1247- $ formattedShare = $ this ->formatShare ($ share , $ node );
1245+ try {
1246+ $ formattedShare = $ this ->formatShare ($ share , $ node );
12481247 $ formattedShare ['status ' ] = $ share ->getStatus ();
12491248 $ formattedShare ['path ' ] = $ share ->getNode ()->getName ();
12501249 $ formattedShare ['permissions ' ] = 0 ;
@@ -1735,7 +1734,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
17351734 }
17361735
17371736 if ($ share ->getShareType () === IShare::TYPE_CIRCLE && \OC ::$ server ->getAppManager ()->isEnabledForUser ('circles ' )
1738- && class_exists ('\OCA\Circles\Api\v1\Circles ' )) {
1737+ && class_exists ('\OCA\Circles\CirclesManager ' )) {
17391738 $ hasCircleId = (substr ($ share ->getSharedWith (), -1 ) === '] ' );
17401739 $ shareWithStart = ($ hasCircleId ? strrpos ($ share ->getSharedWith (), '[ ' ) + 1 : 0 );
17411740 $ shareWithLength = ($ hasCircleId ? -1 : strpos ($ share ->getSharedWith (), ' ' ));
@@ -1745,12 +1744,22 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
17451744 $ sharedWith = substr ($ share ->getSharedWith (), $ shareWithStart , $ shareWithLength );
17461745 }
17471746 try {
1748- $ member = \OCA \Circles \Api \v1 \Circles::getMember ($ sharedWith , $ userId , 1 );
1749- if ($ member ->getLevel () >= 4 ) {
1750- return true ;
1747+ // TODO: switch to ICirclesManager once we have it available within core
1748+ /** @var \OCA\Circles\CirclesManager $circleManager */
1749+ $ circleManager = $ this ->serverContainer ->get ('\OCA\Circles\CirclesManager ' );
1750+ $ circleManager ->startSuperSession ();
1751+
1752+ // We get the federatedUser linked to the userId (local user, so type=1)
1753+ // We browse the federatedUser's membership to confirm it exists and level is moderator
1754+ $ federatedUser = $ circleManager ->getFederatedUser ($ userId , 1 );
1755+ foreach ($ federatedUser ->getMemberships () as $ membership ) {
1756+ if ($ membership ->getCircleId () !== $ sharedWith ) {
1757+ continue ;
1758+ }
1759+
1760+ return ($ membership ->getLevel () >= 4 );
17511761 }
1752- return false ;
1753- } catch (QueryException $ e ) {
1762+ } catch (\Exception $ e ) {
17541763 return false ;
17551764 }
17561765 }
0 commit comments