Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(Sharing): Do not create new share in guest app
Only create the template for share and return the the 'Sharing UI'
in the sidebar.

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Jun 26, 2024
commit 809108d3a8b56c854ef63476153b9b49a924466f
37 changes: 37 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@nextcloud/dialogs": "^4.0.1",
"@nextcloud/event-bus": "^3.0.2",
"@nextcloud/router": "^2.0.1",
"@nextcloud/sharing": "^0.2.2",
"@nextcloud/vue": "^7.11.4",
"email-validator": "^2.0.4",
"vue": "^2.7.14",
Expand Down
6 changes: 6 additions & 0 deletions src/services/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getLoggerBuilder } from '@nextcloud/logger'

export const logger = getLoggerBuilder()
.setApp('guests')
.detectUser()
.build()
23 changes: 11 additions & 12 deletions src/views/GuestForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
</template>

<script>
import { logger } from '../services/logger.ts'
import { generateOcsUrl } from '@nextcloud/router'
import { Type as ShareTypes } from '@nextcloud/sharing'

import AccountPlus from 'vue-material-design-icons/AccountPlus.vue'
import axios from '@nextcloud/axios'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
Expand Down Expand Up @@ -200,6 +203,7 @@ export default {

this.loading = true
try {

await axios.put(generateOcsUrl('/apps/guests/api/v1/users'), {
displayName: this.guest.fullName,
email: this.guest.email,
Expand All @@ -216,7 +220,8 @@ export default {
this.closeModal()
return
}
await this.addGuestShare()

await this.setupGuestShare()
} catch ({ response }) {
const error = response && response.data && response.data.ocs && response.data.ocs.data
? response.data.ocs.data.errorMessages
Expand All @@ -230,22 +235,16 @@ export default {
}
},

async addGuestShare() {
async setupGuestShare() {
try {
const url = generateOcsUrl('/apps/files_sharing/api/v1/shares')
const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')

const result = await axios.post(url + '?format=json', {
shareType: OC.Share.SHARE_TYPE_USER,
const shareTemplate = {
shareType: ShareTypes.SHARE_TYPE_USER,
shareWith: this.guest.username,
path,
})

if (!result.data.ocs) {
this.reject(result)
}

this.resolve(result.data.ocs.data)
logger.info('Created share template with newly invited guest', { shareTemplate })
this.resolve(shareTemplate)
this.closeModal()
} catch ({ response }) {
this.reject(response)
Expand Down