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

Commit

Permalink
Enforce recipient shareType
Browse files Browse the repository at this point in the history
  • Loading branch information
JanAckermann committed Apr 26, 2022
1 parent 453c5e6 commit 919e352
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shareInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ class ShareInfo {
}
}

module.exports = ShareInfo
module.exports = { ShareInfo, USER_TYPE_GUEST, SHARE_TYPE_GUEST }
17 changes: 15 additions & 2 deletions src/shareManagement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Promise = require('promise')
const parser = require('./xmlParser.js')
const ShareInfo = require('./shareInfo.js')
const { ShareInfo, USER_TYPE_GUEST, SHARE_TYPE_GUEST } = require('./shareInfo.js')

/**
* @class Shares
Expand Down Expand Up @@ -469,7 +469,20 @@ class Shares {
throw new Error(response.status + '/' + response.statusText)
})
.then(json => {
return json.ocs.data
const data = json.ocs.data

/**
* oC10 does not emit if a share recipient is a user or a guest,
* therefore we check if the property `userType` is present and set to `USER_TYPE_GUEST`,
* if so we manipulate the `shareType` property and set it to `SHARE_TYPE_GUEST`
*/
data.users.forEach((user) => {
if (user.value.userType === parseInt(USER_TYPE_GUEST)) {
user.value.shareType = parseInt(SHARE_TYPE_GUEST)
}
})

return data
})
}

Expand Down

0 comments on commit 919e352

Please sign in to comment.