Skip to content

Commit

Permalink
Merge pull request #21032 from nextcloud/backport/20846/stable19
Browse files Browse the repository at this point in the history
[stable19] Link permissions
  • Loading branch information
rullzer authored May 19, 2020
2 parents 231eaf6 + dd15780 commit e003fcd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
19 changes: 10 additions & 9 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,6 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
$result['expiration'] = $expiration->format('Y-m-d 00:00:00');
}

// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
// For link shares, we need to have the PERMISSION_SHARE if federated is enabled
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
if ($share->getShareType() === IShare::TYPE_LINK
|| $share->getShareType() === IShare::TYPE_EMAIL) {
$result['permissions'] |= Constants::PERMISSION_SHARE;
}
}

if ($share->getShareType() === IShare::TYPE_USER) {
$sharedWith = $this->userManager->get($share->getSharedWith());
$result['share_with'] = $share->getSharedWith();
Expand Down Expand Up @@ -511,6 +502,11 @@ public function createShare(
$permissions = Constants::PERMISSION_READ;
}

// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
if (($permissions & Constants::PERMISSION_READ) && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
$permissions |= Constants::PERMISSION_SHARE;
}

$share->setPermissions($permissions);

// Set password
Expand Down Expand Up @@ -1055,6 +1051,11 @@ public function updateShare(
}

if ($newPermissions !== null) {
// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
if (($newPermissions & Constants::PERMISSION_READ) && $this->shareManager->outgoingServer2ServerSharesAllowed()) {
$newPermissions |= Constants::PERMISSION_SHARE;
}

$share->setPermissions($newPermissions);
$permissions = $newPermissions;
}
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,8 @@ public function testUpdateShareUpload() {
\OCP\Constants::PERMISSION_READ |
\OCP\Constants::PERMISSION_CREATE |
\OCP\Constants::PERMISSION_UPDATE |
\OCP\Constants::PERMISSION_DELETE,
\OCP\Constants::PERMISSION_DELETE |
\OCP\Constants::PERMISSION_SHARE,
$share1->getPermissions()
);

Expand Down
4 changes: 2 additions & 2 deletions build/integration/sharing_features/sharing-v1.feature
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Feature: sharing
| share_type | 3 |
| file_source | A_NUMBER |
| file_target | /FOLDER |
| permissions | 15 |
| permissions | 31 |
| stime | A_NUMBER |
| token | A_TOKEN |
| storage | A_NUMBER |
Expand Down Expand Up @@ -259,7 +259,7 @@ Feature: sharing
| share_type | 3 |
| file_source | A_NUMBER |
| file_target | /FOLDER |
| permissions | 15 |
| permissions | 31 |
| stime | A_NUMBER |
| token | A_TOKEN |
| storage | A_NUMBER |
Expand Down

0 comments on commit e003fcd

Please sign in to comment.