Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Add space_ref for link- and group-shares
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Mar 22, 2022
1 parent b5df7ff commit f0074ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-share-spaces
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 13 additions & 6 deletions src/shareManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -169,6 +171,11 @@ class Shares {
}

if (optionalParams) {
if (optionalParams.spaceRef) {
postData.space_ref = optionalParams.spaceRef
delete postData.path
}

postData = { ...postData, ...this._getOptionalParams(optionalParams) }
}

Expand All @@ -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)
Expand Down

0 comments on commit f0074ac

Please sign in to comment.