]> source.dussan.org Git - nextcloud-server.git/commitdiff
Have share permissions on link shares if it is enabled
authorRoeland Jago Douma <roeland@famdouma.nl>
Wed, 6 May 2020 19:39:49 +0000 (21:39 +0200)
committerJulius Härtl <jus@bitgrid.net>
Fri, 15 May 2020 06:18:03 +0000 (08:18 +0200)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/files_sharing/lib/Controller/ShareAPIController.php

index 49320d57f16f5622a3de6bf13245a97849856baf..0fbd57b471334e71c14c18423d4c47e001683664 100644 (file)
@@ -216,15 +216,6 @@ class ShareAPIController extends OCSController {
                        $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();
@@ -511,6 +502,11 @@ class ShareAPIController extends OCSController {
                                $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
@@ -1055,6 +1051,11 @@ class ShareAPIController extends OCSController {
                        }
 
                        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;
                        }