@@ -320,6 +320,14 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
320320 $ result = array_merge ($ result , $ this ->getDeckShareHelper ()->formatShare ($ share ));
321321 } catch (QueryException $ e ) {
322322 }
323+ } elseif ($ share ->getShareType () === IShare::TYPE_SCIENCEMESH ) {
324+ $ result ['share_with ' ] = $ share ->getSharedWith ();
325+ $ result ['share_with_displayname ' ] = '' ;
326+
327+ try {
328+ $ result = array_merge ($ result , $ this ->getSciencemeshShareHelper ()->formatShare ($ share ));
329+ } catch (QueryException $ e ) {
330+ }
323331 }
324332
325333
@@ -692,6 +700,12 @@ public function createShare(
692700 } catch (QueryException $ e ) {
693701 throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support room shares ' , [$ node ->getPath ()]));
694702 }
703+ } elseif ($ shareType === IShare::TYPE_SCIENCEMESH ) {
704+ try {
705+ $ this ->getSciencemeshShareHelper ()->createShare ($ share , $ shareWith , $ permissions , $ expireDate );
706+ } catch (QueryException $ e ) {
707+ throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support sciencemesh shares ' , [$ node ->getPath ()]));
708+ }
695709 } else {
696710 throw new OCSBadRequestException ($ this ->l ->t ('Unknown share type ' ));
697711 }
@@ -730,8 +744,9 @@ private function getSharedWithMe($node, bool $includeTags): array {
730744 $ circleShares = $ this ->shareManager ->getSharedWith ($ this ->currentUser , IShare::TYPE_CIRCLE , $ node , -1 , 0 );
731745 $ roomShares = $ this ->shareManager ->getSharedWith ($ this ->currentUser , IShare::TYPE_ROOM , $ node , -1 , 0 );
732746 $ deckShares = $ this ->shareManager ->getSharedWith ($ this ->currentUser , IShare::TYPE_DECK , $ node , -1 , 0 );
747+ $ sciencemeshShares = $ this ->shareManager ->getSharedWith ($ this ->currentUser , IShare::TYPE_SCIENCEMESH , $ node , -1 , 0 );
733748
734- $ shares = array_merge ($ userShares , $ groupShares , $ circleShares , $ roomShares , $ deckShares );
749+ $ shares = array_merge ($ userShares , $ groupShares , $ circleShares , $ roomShares , $ deckShares, $ sciencemeshShares );
735750
736751 $ filteredShares = array_filter ($ shares , function (IShare $ share ) {
737752 return $ share ->getShareOwner () !== $ this ->currentUser ;
@@ -1414,6 +1429,14 @@ protected function canAccessShare(\OCP\Share\IShare $share, bool $checkGroups =
14141429 }
14151430 }
14161431
1432+ if ($ share ->getShareType () === IShare::TYPE_SCIENCEMESH ) {
1433+ try {
1434+ return $ this ->getSciencemeshShareHelper ()->canAccessShare ($ share , $ this ->currentUser );
1435+ } catch (QueryException $ e ) {
1436+ return false ;
1437+ }
1438+ }
1439+
14171440 return false ;
14181441 }
14191442
@@ -1490,7 +1513,8 @@ protected function canDeleteShare(\OCP\Share\IShare $share): bool {
14901513 protected function canDeleteShareFromSelf (\OCP \Share \IShare $ share ): bool {
14911514 if ($ share ->getShareType () !== IShare::TYPE_GROUP &&
14921515 $ share ->getShareType () !== IShare::TYPE_ROOM &&
1493- $ share ->getShareType () !== IShare::TYPE_DECK
1516+ $ share ->getShareType () !== IShare::TYPE_DECK &&
1517+ $ share ->getShareType () !== IShare::TYPE_SCIENCEMESH
14941518 ) {
14951519 return false ;
14961520 }
@@ -1527,6 +1551,14 @@ protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool {
15271551 }
15281552 }
15291553
1554+ if ($ share ->getShareType () === IShare::TYPE_SCIENCEMESH ) {
1555+ try {
1556+ return $ this ->getSciencemeshShareHelper ()->canAccessShare ($ share , $ this ->currentUser );
1557+ } catch (QueryException $ e ) {
1558+ return false ;
1559+ }
1560+ }
1561+
15301562 return false ;
15311563 }
15321564
@@ -1606,6 +1638,15 @@ private function getShareById(string $id): IShare {
16061638 // Do nothing, just try the other share type
16071639 }
16081640
1641+ try {
1642+ if ($ this ->shareManager ->shareProviderExists (IShare::TYPE_SCIENCEMESH )) {
1643+ $ share = $ this ->shareManager ->getShareById ('sciencemesh: ' . $ id , $ this ->currentUser );
1644+ return $ share ;
1645+ }
1646+ } catch (ShareNotFound $ e ) {
1647+ // Do nothing, just try the other share type
1648+ }
1649+
16091650 if (!$ this ->shareManager ->outgoingServer2ServerSharesAllowed ()) {
16101651 throw new ShareNotFound ();
16111652 }
@@ -1669,6 +1710,23 @@ private function getDeckShareHelper() {
16691710 return $ this ->serverContainer ->get ('\OCA\Deck\Sharing\ShareAPIHelper ' );
16701711 }
16711712
1713+ /**
1714+ * Returns the helper of ShareAPIHelper for sciencemesh shares.
1715+ *
1716+ * If the sciencemesh application is not enabled or the helper is not available
1717+ * a QueryException is thrown instead.
1718+ *
1719+ * @return \OCA\Deck\Sharing\ShareAPIHelper
1720+ * @throws QueryException
1721+ */
1722+ private function getSciencemeshShareHelper () {
1723+ if (!$ this ->appManager ->isEnabledForUser ('sciencemesh ' )) {
1724+ throw new QueryException ();
1725+ }
1726+
1727+ return $ this ->serverContainer ->get ('\OCA\ScienceMesh\Sharing\ShareAPIHelper ' );
1728+ }
1729+
16721730 /**
16731731 * @param string $viewer
16741732 * @param Node $node
@@ -1684,7 +1742,8 @@ private function getSharesFromNode(string $viewer, $node, bool $reShares): array
16841742 IShare::TYPE_EMAIL ,
16851743 IShare::TYPE_CIRCLE ,
16861744 IShare::TYPE_ROOM ,
1687- IShare::TYPE_DECK
1745+ IShare::TYPE_DECK ,
1746+ IShare::TYPE_SCIENCEMESH
16881747 ];
16891748
16901749 // Should we assume that the (currentUser) viewer is the owner of the node !?
@@ -1837,8 +1896,12 @@ private function getAllShares(?Node $path = null, bool $reshares = false) {
18371896 // TALK SHARES
18381897 $ roomShares = $ this ->shareManager ->getSharesBy ($ this ->currentUser , IShare::TYPE_ROOM , $ path , $ reshares , -1 , 0 );
18391898
1899+ // DECK SHARES
18401900 $ deckShares = $ this ->shareManager ->getSharesBy ($ this ->currentUser , IShare::TYPE_DECK , $ path , $ reshares , -1 , 0 );
18411901
1902+ // SCIENCEMESH SHARES
1903+ $ sciencemeshShares = $ this ->shareManager ->getSharesBy ($ this ->currentUser , IShare::TYPE_SCIENCEMESH , $ path , $ reshares , -1 , 0 );
1904+
18421905 // FEDERATION
18431906 if ($ this ->shareManager ->outgoingServer2ServerSharesAllowed ()) {
18441907 $ federatedShares = $ this ->shareManager ->getSharesBy ($ this ->currentUser , IShare::TYPE_REMOTE , $ path , $ reshares , -1 , 0 );
@@ -1851,7 +1914,7 @@ private function getAllShares(?Node $path = null, bool $reshares = false) {
18511914 $ federatedGroupShares = [];
18521915 }
18531916
1854- return array_merge ($ userShares , $ groupShares , $ linkShares , $ mailShares , $ circleShares , $ roomShares , $ deckShares , $ federatedShares , $ federatedGroupShares );
1917+ return array_merge ($ userShares , $ groupShares , $ linkShares , $ mailShares , $ circleShares , $ roomShares , $ deckShares , $ sciencemeshShares , $ federatedShares , $ federatedGroupShares );
18551918 }
18561919
18571920
0 commit comments