|
|
|
|
@ -277,7 +277,7 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
/** @var array{share_with_displayname: string, share_with_link: string, share_with?: string, token?: string} $roomShare */
|
|
|
|
|
$roomShare = $this->getRoomShareHelper()->formatShare($share);
|
|
|
|
|
$result = array_merge($result, $roomShare);
|
|
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
} catch (ContainerExceptionInterface $e) {
|
|
|
|
|
}
|
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
|
|
|
|
|
$result['share_with'] = $share->getSharedWith();
|
|
|
|
|
@ -287,7 +287,7 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
/** @var array{share_with: string, share_with_displayname: string, share_with_link: string} $deckShare */
|
|
|
|
|
$deckShare = $this->getDeckShareHelper()->formatShare($share);
|
|
|
|
|
$result = array_merge($result, $deckShare);
|
|
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
} catch (ContainerExceptionInterface $e) {
|
|
|
|
|
}
|
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
|
|
|
|
|
$result['share_with'] = $share->getSharedWith();
|
|
|
|
|
@ -297,7 +297,7 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
/** @var array{share_with: string, share_with_displayname: string, token: string} $scienceMeshShare */
|
|
|
|
|
$scienceMeshShare = $this->getSciencemeshShareHelper()->formatShare($share);
|
|
|
|
|
$result = array_merge($result, $scienceMeshShare);
|
|
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
} catch (ContainerExceptionInterface $e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -632,7 +632,9 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
$share = $this->setShareAttributes($share, $attributes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expire date
|
|
|
|
|
// Expire date checks
|
|
|
|
|
// Normally, null means no expiration date but we still set the default for backwards compatibility
|
|
|
|
|
// If the client sends an empty string, we set noExpirationDate to true
|
|
|
|
|
if ($expireDate !== null) {
|
|
|
|
|
if ($expireDate !== '') {
|
|
|
|
|
try {
|
|
|
|
|
@ -746,7 +748,7 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
$share->setSharedWith($shareWith);
|
|
|
|
|
$share->setPermissions($permissions);
|
|
|
|
|
} elseif ($shareType === IShare::TYPE_CIRCLE) {
|
|
|
|
|
if (!\OC::$server->getAppManager()->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
|
|
|
|
|
if (!\OCP\Server::get(IAppManager::class)->isEnabledForUser('circles') || !class_exists('\OCA\Circles\ShareByCircleProvider')) {
|
|
|
|
|
throw new OCSNotFoundException($this->l->t('You cannot share to a Team if the app is not enabled'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -761,19 +763,19 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
} elseif ($shareType === IShare::TYPE_ROOM) {
|
|
|
|
|
try {
|
|
|
|
|
$this->getRoomShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? '');
|
|
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
} catch (ContainerExceptionInterface $e) {
|
|
|
|
|
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()]));
|
|
|
|
|
}
|
|
|
|
|
} elseif ($shareType === IShare::TYPE_DECK) {
|
|
|
|
|
try {
|
|
|
|
|
$this->getDeckShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? '');
|
|
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
} catch (ContainerExceptionInterface $e) {
|
|
|
|
|
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()]));
|
|
|
|
|
}
|
|
|
|
|
} elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
|
|
|
|
|
try {
|
|
|
|
|
$this->getSciencemeshShareHelper()->createShare($share, $shareWith, $permissions, $expireDate ?? '');
|
|
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
} catch (ContainerExceptionInterface $e) {
|
|
|
|
|
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support ScienceMesh shares', [$node->getPath()]));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
@ -1765,10 +1767,10 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
* Returns the helper of ShareAPIController for room shares.
|
|
|
|
|
*
|
|
|
|
|
* If the Talk application is not enabled or the helper is not available
|
|
|
|
|
* a QueryException is thrown instead.
|
|
|
|
|
* a ContainerExceptionInterface is thrown instead.
|
|
|
|
|
*
|
|
|
|
|
* @return \OCA\Talk\Share\Helper\ShareAPIController
|
|
|
|
|
* @throws QueryException
|
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
|
*/
|
|
|
|
|
private function getRoomShareHelper() {
|
|
|
|
|
if (!$this->appManager->isEnabledForUser('spreed')) {
|
|
|
|
|
@ -1782,10 +1784,10 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
* 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.
|
|
|
|
|
* a ContainerExceptionInterface is thrown instead.
|
|
|
|
|
*
|
|
|
|
|
* @return \OCA\Deck\Sharing\ShareAPIHelper
|
|
|
|
|
* @throws QueryException
|
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
|
*/
|
|
|
|
|
private function getDeckShareHelper() {
|
|
|
|
|
if (!$this->appManager->isEnabledForUser('deck')) {
|
|
|
|
|
@ -1799,10 +1801,10 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
* Returns the helper of ShareAPIHelper for sciencemesh shares.
|
|
|
|
|
*
|
|
|
|
|
* If the sciencemesh application is not enabled or the helper is not available
|
|
|
|
|
* a QueryException is thrown instead.
|
|
|
|
|
* a ContainerExceptionInterface is thrown instead.
|
|
|
|
|
*
|
|
|
|
|
* @return \OCA\Deck\Sharing\ShareAPIHelper
|
|
|
|
|
* @throws QueryException
|
|
|
|
|
* @throws ContainerExceptionInterface
|
|
|
|
|
*/
|
|
|
|
|
private function getSciencemeshShareHelper() {
|
|
|
|
|
if (!$this->appManager->isEnabledForUser('sciencemesh')) {
|
|
|
|
|
@ -1935,7 +1937,7 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($share->getShareType() === IShare::TYPE_CIRCLE && \OC::$server->getAppManager()->isEnabledForUser('circles')
|
|
|
|
|
if ($share->getShareType() === IShare::TYPE_CIRCLE && \OCP\Server::get(IAppManager::class)->isEnabledForUser('circles')
|
|
|
|
|
&& class_exists('\OCA\Circles\Api\v1\Circles')) {
|
|
|
|
|
$hasCircleId = (str_ends_with($share->getSharedWith(), ']'));
|
|
|
|
|
$shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0);
|
|
|
|
|
@ -1951,7 +1953,7 @@ class ShareAPIController extends OCSController {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
} catch (QueryException $e) {
|
|
|
|
|
} catch (ContainerExceptionInterface $e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|