6969</template >
7070
7171<script >
72+ import { logger } from ' ../services/logger.ts'
7273import { generateOcsUrl } from ' @nextcloud/router'
74+ import { Type as ShareTypes } from ' @nextcloud/sharing'
75+
7376import AccountPlus from ' vue-material-design-icons/AccountPlus.vue'
7477import axios from ' @nextcloud/axios'
7578import 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