diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-04-27 11:05:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 11:05:34 +0200 |
commit | 1738e17e204c813bc3ab970e18a94b415c41af41 (patch) | |
tree | 202f06b32ed14fe2a08ab446be9242ac15382bc3 /apps | |
parent | a64681a0fed38eb1652ddf3dd9aeeefb2a021f11 (diff) | |
parent | 7a9469f282471168a48acdcbed84579bd93efa43 (diff) | |
download | nextcloud-server-1738e17e204c813bc3ab970e18a94b415c41af41.tar.gz nextcloud-server-1738e17e204c813bc3ab970e18a94b415c41af41.zip |
Merge pull request #19793 from nextcloud/bugfix/noid/link-to-federated-reshare
Fix resharing of federated shares that were created out of links
Diffstat (limited to 'apps')
-rw-r--r-- | apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 13 | ||||
-rw-r--r-- | apps/files_sharing/tests/ApiTest.php | 7 |
3 files changed, 15 insertions, 7 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index 64e12fcd251..cfd759a4d19 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -43,6 +43,7 @@ use OCP\IRequest; use OCP\ISession; use OCP\IUserSession; use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class MountPublicLinkController @@ -155,6 +156,7 @@ class MountPublicLinkController extends Controller { } $share->setSharedWith($shareWith); + $share->setShareType(IShare::TYPE_REMOTE); try { $this->federatedShareProvider->create($share); diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 37dc76faaaf..12324daea39 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -492,15 +492,18 @@ class ShareAPIController extends OCSController { throw new OCSNotFoundException($this->l->t('Public upload is only possible for publicly shared folders')); } - $share->setPermissions( - Constants::PERMISSION_READ | + $permissions = Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | - Constants::PERMISSION_DELETE - ); + Constants::PERMISSION_DELETE; } else { - $share->setPermissions(Constants::PERMISSION_READ); + $permissions = Constants::PERMISSION_READ; + } + // TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones + if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { + $permissions |= Constants::PERMISSION_SHARE; } + $share->setPermissions($permissions); // Set password if ($password !== '') { diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 6bbb62d6090..f4100bd5e82 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -203,7 +203,9 @@ class ApiTest extends TestCase { $ocs->cleanup(); $data = $result->getData(); - $this->assertEquals(1, $data['permissions']); + $this->assertEquals(\OCP\Constants::PERMISSION_READ | + \OCP\Constants::PERMISSION_SHARE, + $data['permissions']); $this->assertEmpty($data['expiration']); $this->assertTrue(is_string($data['token'])); @@ -228,7 +230,8 @@ class ApiTest extends TestCase { \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | - \OCP\Constants::PERMISSION_DELETE, + \OCP\Constants::PERMISSION_DELETE | + \OCP\Constants::PERMISSION_SHARE, $data['permissions'] ); $this->assertEmpty($data['expiration']); |