]> source.dussan.org Git - nextcloud-server.git/commitdiff
refactor(files_sharing): Make permissions prop checks less error prone
authorprovokateurin <kate@provokateurin.de>
Thu, 26 Sep 2024 07:41:49 +0000 (09:41 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 26 Sep 2024 14:23:55 +0000 (14:23 +0000)
Signed-off-by: provokateurin <kate@provokateurin.de>
apps/files_sharing/lib/External/Storage.php

index 020bbe2fbf9ef7a66f6226c75ef2ed58e2abc5dc..a85e32f7619aef3152d545a14778fa0951d483a7 100644 (file)
@@ -357,14 +357,17 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
 
        public function getPermissions($path): int {
                $response = $this->propfind($path);
+               $ocsPermissions = $response['{http://open-collaboration-services.org/ns}share-permissions'] ?? null;
+               $ocmPermissions = $response['{http://open-cloud-mesh.org/ns}share-permissions'] ?? null;
+               $ocPermissions = $response['{http://owncloud.org/ns}permissions'] ?? null;
                // old federated sharing permissions
-               if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) {
-                       $permissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions'];
-               } elseif (isset($response['{http://open-cloud-mesh.org/ns}share-permissions'])) {
+               if ($ocsPermissions !== null) {
+                       $permissions = (int)$ocsPermissions;
+               } elseif ($ocmPermissions !== null) {
                        // permissions provided by the OCM API
-                       $permissions = $this->ocmPermissions2ncPermissions($response['{http://open-cloud-mesh.org/ns}share-permissions'], $path);
-               } elseif (isset($response['{http://owncloud.org/ns}permissions'])) {
-                       return $this->parsePermissions($response['{http://owncloud.org/ns}permissions']);
+                       $permissions = $this->ocmPermissions2ncPermissions($ocmPermissions, $path);
+               } elseif ($ocPermissions !== null) {
+                       return $this->parsePermissions($ocPermissions);
                } else {
                        // use default permission if remote server doesn't provide the share permissions
                        $permissions = $this->getDefaultPermissions($path);