Skip to content

Commit 95ecc83

Browse files
committed
refactor(files_sharing,Share20): Use Interaction API to apply restrictions
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 69483cd commit 95ecc83

6 files changed

Lines changed: 849 additions & 760 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -724,10 +724,6 @@ public function createShare(
724724
$share->setSharedWith($shareWith);
725725
$share->setPermissions($permissions);
726726
} elseif ($shareType === IShare::TYPE_GROUP) {
727-
if (!$this->shareManager->allowGroupSharing()) {
728-
throw new OCSNotFoundException($this->l->t('Group sharing is disabled by the administrator'));
729-
}
730-
731727
// Valid group is required to share
732728
if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) {
733729
throw new OCSNotFoundException($this->l->t('Please specify a valid group'));
@@ -737,11 +733,6 @@ public function createShare(
737733
} elseif ($shareType === IShare::TYPE_LINK
738734
|| $shareType === IShare::TYPE_EMAIL) {
739735

740-
// Can we even share links?
741-
if (!$this->shareManager->shareApiAllowLinks()) {
742-
throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator'));
743-
}
744-
745736
$this->validateLinkSharePermissions($node, $permissions, $hasPublicUpload);
746737
$share->setPermissions($permissions);
747738

@@ -775,10 +766,6 @@ public function createShare(
775766
$share->setSendPasswordByTalk(true);
776767
}
777768
} elseif ($shareType === IShare::TYPE_REMOTE) {
778-
if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
779-
throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$node->getPath(), $shareType]));
780-
}
781-
782769
if ($shareWith === null) {
783770
throw new OCSNotFoundException($this->l->t('Please specify a valid federated account ID'));
784771
}
@@ -787,10 +774,6 @@ public function createShare(
787774
$share->setPermissions($permissions);
788775
$share->setSharedWithDisplayName($this->getCachedFederatedDisplayName($shareWith, false));
789776
} elseif ($shareType === IShare::TYPE_REMOTE_GROUP) {
790-
if (!$this->shareManager->outgoingServer2ServerGroupSharesAllowed()) {
791-
throw new OCSForbiddenException($this->l->t('Sharing %1$s failed because the back end does not allow shares from type %2$s', [$node->getPath(), $shareType]));
792-
}
793-
794777
if ($shareWith === null) {
795778
throw new OCSNotFoundException($this->l->t('Please specify a valid federated group ID'));
796779
}
@@ -1049,12 +1032,6 @@ private function validateLinkSharePermissions(Node $node, int $permissions, ?boo
10491032
&& ($this->hasPermission($permissions, Constants::PERMISSION_UPDATE) || $this->hasPermission($permissions, Constants::PERMISSION_DELETE))) {
10501033
throw new OCSBadRequestException($this->l->t('Share must have READ permission if UPDATE or DELETE permission is set'));
10511034
}
1052-
1053-
// Check if public uploading was disabled
1054-
if ($this->hasPermission($permissions, Constants::PERMISSION_CREATE)
1055-
&& !$this->shareManager->shareApiLinkAllowPublicUpload()) {
1056-
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
1057-
}
10581035
}
10591036

10601037
/**

0 commit comments

Comments
 (0)