Skip to content
Closed
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
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()
25 changes: 12 additions & 13 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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need some adaptation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artonge no, assumed this was cover 27


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 All @@ -258,7 +257,7 @@ export default {
this.groups = result.data.ocs.data.groups
this.groupRequired = result.data.ocs.data.required
} catch (error) {
console.error('Failed to retrieve groups', error)
logger.error('Failed to retrieve groups', { error })
}
},

Expand Down