diff options
-rw-r--r-- | src/components/NewMessageForm/NewMessageForm.vue | 10 | ||||
-rw-r--r-- | src/services/filesSharingServices.js | 6 | ||||
-rw-r--r-- | src/store/fileUploadStore.js | 7 | ||||
-rw-r--r-- | src/store/messagesStore.js | 4 |
4 files changed, 16 insertions, 11 deletions
diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index 0cf2b45ec..84b25e943 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -405,12 +405,14 @@ export default { * * @param {File[] | FileList} files pasted files list * @param {bool} rename whether to rename the files + * @param {bool} isVoiceMessage indicates whether the file is a vooicemessage + */ - async handleFiles(files, rename = false) { - // Create a unique id for the upload operation + async handleFiles(files, rename = false, isVoiceMessage) { + // Create a unique id for the upload operation const uploadId = new Date().getTime() // Uploads and shares the files - await this.$store.dispatch('initialiseUpload', { files, token: this.token, uploadId, rename }) + await this.$store.dispatch('initialiseUpload', { files, token: this.token, uploadId, rename, isVoiceMessage }) }, /** @@ -462,7 +464,7 @@ export default { }, handleAudioFile(payload) { - this.handleFiles([payload]) + this.handleFiles([payload], false, true) }, handleRecording(payload) { diff --git a/src/services/filesSharingServices.js b/src/services/filesSharingServices.js index 35ad3470b..6fa40ab94 100644 --- a/src/services/filesSharingServices.js +++ b/src/services/filesSharingServices.js @@ -29,8 +29,9 @@ import { showError } from '@nextcloud/dialogs' * @param {string} token The conversation's token * e.g. `/myfile.txt` * @param {string} referenceId An optional reference id to recognize the message later - */ -const shareFile = async function(path, token, referenceId) { + * @param {array} metadata the metadata json encoded array +*/ +const shareFile = async function(path, token, referenceId, metadata) { try { return axios.post( generateOcsUrl('apps/files_sharing/api/v1/shares'), @@ -39,6 +40,7 @@ const shareFile = async function(path, token, referenceId) { path, shareWith: token, referenceId, + talkMetaData: metadata, }) } catch (error) { // FIXME: errors should be handled by called instead diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index 1f0385f16..b24aebcf4 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -194,7 +194,7 @@ const actions = { * @param {number} uploadId a unique id for the upload operation indexing * @param {bool} rename whether to rename the files (usually after pasting) */ - async initialiseUpload({ commit, dispatch }, { uploadId, token, files, rename = false }) { + async initialiseUpload({ commit, dispatch }, { uploadId, token, files, rename = false, isVoiceMessage }) { // Set last upload id commit('setCurrentUploadId', uploadId) @@ -219,7 +219,7 @@ const actions = { const index = 'temp_' + date.getTime() + Math.random() // Create temporary message for the file and add it to the message list const temporaryMessage = await dispatch('createTemporaryMessage', { - text: '{file}', token, uploadId, index, file, localUrl, + text: '{file}', token, uploadId, index, file, localUrl, isVoiceMessage, }) console.debug('temporarymessage: ', temporaryMessage, 'uploadId', uploadId) commit('addFileToBeUploaded', { file, temporaryMessage }) @@ -317,10 +317,11 @@ const actions = { for (const index in shareableFiles) { const path = shareableFiles[index].sharePath const temporaryMessage = shareableFiles[index].temporaryMessage + const metadata = JSON.stringify({ 'messageType': temporaryMessage.messageType }) try { const token = temporaryMessage.token dispatch('markFileAsSharing', { uploadId, index }) - await shareFile(path, token, temporaryMessage.referenceId) + await shareFile(path, token, temporaryMessage.referenceId, metadata) dispatch('markFileAsShared', { uploadId, index }) } catch (error) { if (error?.response?.status === 403) { diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index b31721edc..ddcb35875 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -348,7 +348,7 @@ const actions = { * @param {string} localUrl local URL of file to upload; * @returns {object} temporary message */ - createTemporaryMessage(context, { text, token, uploadId, index, file, localUrl }) { + createTemporaryMessage(context, { text, token, uploadId, index, file, localUrl, isVoiceMessage }) { const messageToBeReplied = context.getters.getMessageToBeReplied(token) const date = new Date() let tempId = 'temp-' + date.getTime() @@ -374,7 +374,7 @@ const actions = { actorDisplayName: context.getters.getDisplayName(), timestamp: 0, systemMessage: '', - messageType: '', + messageType: isVoiceMessage ? 'voice-message' : '', message: text, messageParameters, token, |