diff options
Diffstat (limited to 'apps/files_sharing/lib/Controller/ShareAPIController.php')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 68 |
1 files changed, 64 insertions, 4 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index aaca16b32e6..399ff18fba8 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -303,6 +303,14 @@ class ShareAPIController extends OCSController { $result = array_merge($result, $this->getRoomShareHelper()->formatShare($share)); } catch (QueryException $e) { } + } elseif ($share->getShareType() === IShare::TYPE_DECK) { + $result['share_with'] = $share->getSharedWith(); + $result['share_with_displayname'] = ''; + + try { + $result = array_merge($result, $this->getDeckShareHelper()->formatShare($share)); + } catch (QueryException $e) { + } } @@ -603,6 +611,12 @@ class ShareAPIController extends OCSController { } catch (QueryException $e) { throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$path->getPath()])); } + } elseif ($shareType === IShare::TYPE_DECK) { + try { + $this->getDeckShareHelper()->createShare($share, $shareWith, $permissions, $expireDate); + } catch (QueryException $e) { + throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$path->getPath()])); + } } else { throw new OCSBadRequestException($this->l->t('Unknown share type')); } @@ -635,8 +649,9 @@ class ShareAPIController extends OCSController { $groupShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_GROUP, $node, -1, 0); $circleShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_CIRCLE, $node, -1, 0); $roomShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_ROOM, $node, -1, 0); + $deckShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_DECK, $node, -1, 0); - $shares = array_merge($userShares, $groupShares, $circleShares, $roomShares); + $shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares); $filteredShares = array_filter($shares, function (IShare $share) { return $share->getShareOwner() !== $this->currentUser; @@ -1296,6 +1311,14 @@ class ShareAPIController extends OCSController { } } + if ($share->getShareType() === IShare::TYPE_DECK) { + try { + return $this->getDeckShareHelper()->canAccessShare($share, $this->currentUser); + } catch (QueryException $e) { + return false; + } + } + return false; } @@ -1371,7 +1394,8 @@ class ShareAPIController extends OCSController { */ protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool { if ($share->getShareType() !== IShare::TYPE_GROUP && - $share->getShareType() !== IShare::TYPE_ROOM + $share->getShareType() !== IShare::TYPE_ROOM && + $share->getShareType() !== IShare::TYPE_DECK ) { return false; } @@ -1400,6 +1424,14 @@ class ShareAPIController extends OCSController { } } + if ($share->getShareType() === IShare::TYPE_DECK) { + try { + return $this->getDeckShareHelper()->canAccessShare($share, $this->currentUser); + } catch (QueryException $e) { + return false; + } + } + return false; } @@ -1474,6 +1506,15 @@ class ShareAPIController extends OCSController { // Do nothing, just try the other share type } + try { + if ($this->shareManager->shareProviderExists(IShare::TYPE_DECK)) { + $share = $this->shareManager->getShareById('deck:' . $id, $this->currentUser); + return $share; + } + } catch (ShareNotFound $e) { + // Do nothing, just try the other share type + } + if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { throw new ShareNotFound(); } @@ -1520,6 +1561,22 @@ class ShareAPIController extends OCSController { return $this->serverContainer->query('\OCA\Talk\Share\Helper\ShareAPIController'); } + /** + * Returns the helper of ShareAPIHelper for deck shares. + * + * If the Deck application is not enabled or the helper is not available + * a QueryException is thrown instead. + * + * @return \OCA\Deck\Sharing\ShareAPIHelper + * @throws QueryException + */ + private function getDeckShareHelper() { + if (!$this->appManager->isEnabledForUser('deck')) { + throw new QueryException(); + } + + return $this->serverContainer->query('\OCA\Deck\Sharing\ShareAPIHelper'); + } /** * @param string $viewer @@ -1536,7 +1593,8 @@ class ShareAPIController extends OCSController { IShare::TYPE_EMAIL, IShare::TYPE_EMAIL, IShare::TYPE_CIRCLE, - IShare::TYPE_ROOM + IShare::TYPE_ROOM, + IShare::TYPE_DECK ]; // Should we assume that the (currentUser) viewer is the owner of the node !? @@ -1689,6 +1747,8 @@ class ShareAPIController extends OCSController { // TALK SHARES $roomShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_ROOM, $path, $reshares, -1, 0); + $deckShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_DECK, $path, $reshares, -1, 0); + // FEDERATION if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { $federatedShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE, $path, $reshares, -1, 0); @@ -1701,7 +1761,7 @@ class ShareAPIController extends OCSController { $federatedGroupShares = []; } - return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $federatedShares, $federatedGroupShares); + return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $federatedShares, $federatedGroupShares); } |