Skip to content

Commit fb17121

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

6 files changed

Lines changed: 819 additions & 751 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,6 @@ public function createShare(
718718
$share->setSharedWith($shareWith);
719719
$share->setPermissions($permissions);
720720
} elseif ($shareType === IShare::TYPE_GROUP) {
721-
if (!$this->shareManager->allowGroupSharing()) {
722-
throw new OCSNotFoundException($this->l->t('Group sharing is disabled by the administrator'));
723-
}
724-
725721
// Valid group is required to share
726722
if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) {
727723
throw new OCSNotFoundException($this->l->t('Please specify a valid group'));
@@ -731,11 +727,6 @@ public function createShare(
731727
} elseif ($shareType === IShare::TYPE_LINK
732728
|| $shareType === IShare::TYPE_EMAIL) {
733729

734-
// Can we even share links?
735-
if (!$this->shareManager->shareApiAllowLinks()) {
736-
throw new OCSNotFoundException($this->l->t('Public link sharing is disabled by the administrator'));
737-
}
738-
739730
$this->validateLinkSharePermissions($node, $permissions, $hasPublicUpload);
740731
$share->setPermissions($permissions);
741732

@@ -769,10 +760,6 @@ public function createShare(
769760
$share->setSendPasswordByTalk(true);
770761
}
771762
} elseif ($shareType === IShare::TYPE_REMOTE) {
772-
if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
773-
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]));
774-
}
775-
776763
if ($shareWith === null) {
777764
throw new OCSNotFoundException($this->l->t('Please specify a valid federated account ID'));
778765
}
@@ -781,10 +768,6 @@ public function createShare(
781768
$share->setPermissions($permissions);
782769
$share->setSharedWithDisplayName($this->getCachedFederatedDisplayName($shareWith, false));
783770
} elseif ($shareType === IShare::TYPE_REMOTE_GROUP) {
784-
if (!$this->shareManager->outgoingServer2ServerGroupSharesAllowed()) {
785-
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]));
786-
}
787-
788771
if ($shareWith === null) {
789772
throw new OCSNotFoundException($this->l->t('Please specify a valid federated group ID'));
790773
}
@@ -1043,12 +1026,6 @@ private function validateLinkSharePermissions(Node $node, int $permissions, ?boo
10431026
&& ($this->hasPermission($permissions, Constants::PERMISSION_UPDATE) || $this->hasPermission($permissions, Constants::PERMISSION_DELETE))) {
10441027
throw new OCSBadRequestException($this->l->t('Share must have READ permission if UPDATE or DELETE permission is set'));
10451028
}
1046-
1047-
// Check if public uploading was disabled
1048-
if ($this->hasPermission($permissions, Constants::PERMISSION_CREATE)
1049-
&& !$this->shareManager->shareApiLinkAllowPublicUpload()) {
1050-
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
1051-
}
10521029
}
10531030

10541031
/**

0 commit comments

Comments
 (0)