From f0074ac7af6d46fe8aa2803150b3b1371201fd35 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 22 Mar 2022 09:47:17 +0100 Subject: [PATCH] Add space_ref for link- and group-shares --- changelog/unreleased/enhancement-share-spaces | 1 + src/shareManagement.js | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/changelog/unreleased/enhancement-share-spaces b/changelog/unreleased/enhancement-share-spaces index 21c70a275..21f543902 100644 --- a/changelog/unreleased/enhancement-share-spaces +++ b/changelog/unreleased/enhancement-share-spaces @@ -8,3 +8,4 @@ This includes the following changes: https://github.com/owncloud/owncloud-sdk/pull/1013 https://github.com/owncloud/owncloud-sdk/pull/1025 +https://github.com/owncloud/owncloud-sdk/pull/1027 diff --git a/src/shareManagement.js b/src/shareManagement.js index 1c2f564a7..312fced87 100644 --- a/src/shareManagement.js +++ b/src/shareManagement.js @@ -51,6 +51,11 @@ class Shares { } if (optionalParams) { + if (optionalParams.spaceRef) { + postData.space_ref = optionalParams.spaceRef + delete postData.path + } + if (optionalParams.permissions) { postData.permissions = optionalParams.permissions } @@ -90,7 +95,6 @@ class Shares { */ shareFileWithUser (path, username, optionalParams) { path = this.helpers._normalizePath(path) - const urlParams = new URLSearchParams() let postData = { shareType: this.helpers.OCS_SHARE_TYPE_USER, @@ -100,16 +104,14 @@ class Shares { if (optionalParams) { if (optionalParams.spaceRef) { - urlParams.append('space_ref', optionalParams.spaceRef) + postData.space_ref = optionalParams.spaceRef delete postData.path } postData = { ...postData, ...this._getOptionalParams(optionalParams) } } - const urlPath = urlParams.toString() ? `shares?${urlParams.toString()}` : 'shares' - - return this.helpers._makeOCSrequest('POST', this.helpers.OCS_SERVICE_SHARE, urlPath, postData) + return this.helpers._makeOCSrequest('POST', this.helpers.OCS_SERVICE_SHARE, 'shares', postData) .then(data => { const shareData = data.data.ocs.data const share = new ShareInfo(shareData) @@ -169,6 +171,11 @@ class Shares { } if (optionalParams) { + if (optionalParams.spaceRef) { + postData.space_ref = optionalParams.spaceRef + delete postData.path + } + postData = { ...postData, ...this._getOptionalParams(optionalParams) } } @@ -193,7 +200,7 @@ class Shares { let data = 'shares' const send = {} - if (path !== '') { + if (path !== '' || (optionalParams && optionalParams.spaceRef)) { data += '?' send.path = this.helpers._normalizePath(path)