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

feat: add shareSpaceWithGroup #1207

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ yarn-error.log*
*.njsproj
*.sln

/.pnpm-store/

.yarn/*
!.yarn/patches
!.yarn/releases
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-share-space-with-group
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Share space with group

We've added a helper to share a space with a group.

https://github.com/owncloud/owncloud-sdk/pull/1207
3 changes: 2 additions & 1 deletion src/helperFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class helpers {
this.OCS_SHARE_TYPE_GROUP = 1
this.OCS_SHARE_TYPE_LINK = 3
this.OCS_SHARE_TYPE_REMOTE = 6
this.OCS_SHARE_TYPE_SPACE = 7
this.OCS_SHARE_TYPE_SPACE_USER = 7
this.OCS_SHARE_TYPE_SPACE_GROUP = 8

this.instance = null
this._authHeader = null
Expand Down
32 changes: 30 additions & 2 deletions src/shareManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const { ShareInfo, USER_TYPE_GUEST, SHARE_TYPE_GUEST } = require('./shareInfo.js
* <li>shareFileWithUser</li>
* <li>shareSpaceWithUser</li>
* <li>shareFileWithGroup</li>
* <li>shareSpaceWithGroup</li>
* <li>getShares</li>
* <li>isShared</li>
* <li>getShare</li>
Expand Down Expand Up @@ -143,9 +144,36 @@ class Shares {
* @returns {Promise.<error>} string: error message, if any.
*/
shareSpaceWithUser (path, username, spaceId, optionalParams) {
return this.shareSpace(path, username, this.helpers.OCS_SHARE_TYPE_SPACE_USER, spaceId, optionalParams)
}

/**
* Shares a space with specified user
* @param {string} path path to the remote file share
* @param {string} groupName name of the group to share with
* @param {string} spaceId id of the space
* @param {object} optionalParams {permissions: integer, expirationDate: ISO Date, attributes: assoc array (at free disposal)}
* @returns {Promise.<ShareInfo>} instance of class ShareInfo
* @returns {Promise.<error>} string: error message, if any.
*/
shareSpaceWithGroup (path, groupName, spaceId, optionalParams) {
return this.shareSpace(path, groupName, this.helpers.OCS_SHARE_TYPE_SPACE_GROUP, spaceId, optionalParams)
}

/**
* Shares a space with specified user or group
* @param {string} path path to the remote file share
* @param {string} shareWith name of the user or group to share with
* @param {number} shareType share type for the new share
* @param {string} spaceId id of the space
* @param {object} optionalParams {permissions: integer, expirationDate: ISO Date, remoteUser: boolean, attributes: assoc array (at free disposal)}
* @returns {Promise.<ShareInfo>} instance of class ShareInfo
* @returns {Promise.<error>} string: error message, if any.
*/
shareSpace (path, shareWith, shareType, spaceId, optionalParams) {
let postData = {
shareType: this.helpers.OCS_SHARE_TYPE_SPACE,
shareWith: username,
shareType,
shareWith,
space_ref: spaceId
}

Expand Down