Skip to content

Commit 4bb6956

Browse files
committed
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 <fenn25.fn@gmail.com>
1 parent eacd50f commit 4bb6956

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/services/logger.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getLoggerBuilder } from '@nextcloud/logger'
2+
3+
export const logger = getLoggerBuilder()
4+
.setApp('guests')
5+
.detectUser()
6+
.build()

src/views/GuestForm.vue

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
</template>
7070

7171
<script>
72+
import { logger } from '../services/logger.ts'
7273
import { generateOcsUrl } from '@nextcloud/router'
74+
import { Type as ShareTypes } from '@nextcloud/sharing'
75+
7376
import AccountPlus from 'vue-material-design-icons/AccountPlus.vue'
7477
import axios from '@nextcloud/axios'
7578
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
@@ -200,6 +203,7 @@ export default {
200203
201204
this.loading = true
202205
try {
206+
203207
await axios.put(generateOcsUrl('/apps/guests/api/v1/users'), {
204208
displayName: this.guest.fullName,
205209
email: this.guest.email,
@@ -216,7 +220,8 @@ export default {
216220
this.closeModal()
217221
return
218222
}
219-
await this.addGuestShare()
223+
224+
await this.setupGuestShare()
220225
} catch ({ response }) {
221226
const error = response && response.data && response.data.ocs && response.data.ocs.data
222227
? response.data.ocs.data.errorMessages
@@ -230,22 +235,16 @@ export default {
230235
}
231236
},
232237
233-
async addGuestShare() {
238+
async setupGuestShare() {
234239
try {
235-
const url = generateOcsUrl('/apps/files_sharing/api/v1/shares')
236240
const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
237-
238-
const result = await axios.post(url + '?format=json', {
239-
shareType: OC.Share.SHARE_TYPE_USER,
241+
const shareTemplate = {
242+
shareType: ShareTypes.SHARE_TYPE_USER,
240243
shareWith: this.guest.username,
241244
path,
242-
})
243-
244-
if (!result.data.ocs) {
245-
this.reject(result)
246245
}
247-
248-
this.resolve(result.data.ocs.data)
246+
logger.info('Created share template with newly invited guest', { shareTemplate })
247+
this.resolve(shareTemplate)
249248
this.closeModal()
250249
} catch ({ response }) {
251250
this.reject(response)

0 commit comments

Comments
 (0)