diff options
-rw-r--r-- | src/components/NewMessageForm/NewMessageForm.vue | 11 | ||||
-rw-r--r-- | src/services/filesSharingServices.js | 19 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index 3a4a9383d..5223159cd 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -59,7 +59,7 @@ </NcActionButton> <NcActionButton v-if="canShareFiles" :close-after-click="true" - @click.prevent="createTextFile"> + @click.prevent="handleCreateTextFile"> <TextBox slot="icon" :size="20" /> {{ t('spreed', 'Create text file') }} </NcActionButton> @@ -163,7 +163,7 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' import NcEmojiPicker from '@nextcloud/vue/dist/Components/NcEmojiPicker.js' import { EventBus } from '../../services/EventBus.js' -import { shareFile } from '../../services/filesSharingServices.js' +import { shareFile, createTextFile } from '../../services/filesSharingServices.js' import { CONVERSATION, PARTICIPANT } from '../../constants.js' import Paperclip from 'vue-material-design-icons/Paperclip.vue' import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue' @@ -584,8 +584,11 @@ export default { this.showSimplePollsEditor = value }, - createTextFile() { - console.log('asdfsadfsd') + // Create text file and share it to a conversation + async handleCreateTextFile() { + const filePath = 'somesdsaddfsalkjnaasdasdme.md' + await createTextFile(filePath) + shareFile(filePath, this.token) }, }, } diff --git a/src/services/filesSharingServices.js b/src/services/filesSharingServices.js index 2b9b2f1fd..26008a1a7 100644 --- a/src/services/filesSharingServices.js +++ b/src/services/filesSharingServices.js @@ -55,6 +55,25 @@ const shareFile = async function(path, token, referenceId, metadata) { } } +/** + * Share a text file to a conversation + * + * @param { string } filePath the file path + * @return { object } the file object + */ +const createTextFile = async function(filePath) { + try { + return axios.post( + generateOcsUrl('apps/files/api/v1/templates/create'), + { + filePath, + }) + } catch (error) { + console.debug(error) + } +} + export { shareFile, + createTextFile, } |