Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable2.4] fix(Sharing): Do not create new share in guest app #1190

Closed
wants to merge 2 commits into from
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'

Check failure on line 74 in src/views/GuestForm.vue

View workflow job for this annotation

GitHub Actions / eslint

Unable to resolve path to module '@nextcloud/sharing'

Check failure on line 74 in src/views/GuestForm.vue

View workflow job for this annotation

GitHub Actions / eslint

"@nextcloud/sharing" is not found
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 @@

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 @@
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 @@
}
},

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 @@
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
Loading