diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index 2e9c0a0648..1215f58128 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -858,6 +858,7 @@ public function saveAttachment(int $id, ); } + $lastFile = null; foreach ($attachments as $attachment) { $fileName = $attachment->getName() ?? $this->l10n->t('Embedded message %s', [ $attachment->getId(), @@ -874,8 +875,17 @@ public function saveAttachment(int $id, $newFile = $this->userFolder->newFile($fullPath); $newFile->putContent($attachment->getContent()); + $lastFile = $newFile; } - return new JSONResponse(); + + if ($lastFile === null) { + return new JSONResponse(['fileId' => null, 'path' => null]); + } + + return new JSONResponse([ + 'fileId' => $lastFile->getId(), + 'path' => $targetPath, + ]); } /** diff --git a/src/components/MessageAttachment.vue b/src/components/MessageAttachment.vue index 8fb911bdcd..7c1b3583c0 100644 --- a/src/components/MessageAttachment.vue +++ b/src/components/MessageAttachment.vue @@ -85,7 +85,9 @@ import { showError, showSuccess } from '@nextcloud/dialogs' import { FilePickerVue as FilePicker } from '@nextcloud/dialogs/filepicker.js' import { formatFileSize } from '@nextcloud/files' import { translate as t } from '@nextcloud/l10n' +import { generateUrl } from '@nextcloud/router' import { NcActionButton as ActionButton, NcActions as Actions, NcLoadingIcon as IconLoading } from '@nextcloud/vue' +import escapeHtml from 'escape-html' import IconArrow from 'vue-material-design-icons/ArrowLeft.vue' import IconSave from 'vue-material-design-icons/FolderOutline.vue' import IconAdd from 'vue-material-design-icons/Plus.vue' @@ -231,9 +233,20 @@ export default { const id = this.$route.params.threadId try { - await saveAttachmentToFiles(id, this.id, path) + const saved = await saveAttachmentToFiles(id, this.id, path) Logger.info('saved') - showSuccess(t('mail', 'Attachment saved to Files')) + + const fileLocationUrl = generateUrl('/apps/files/files/{fileId}?dir={dir}&openfile=true', { + fileId: saved?.fileId, + dir: saved?.path, + }) + + const savedText = t('mail', 'Attachment saved to Files') + const goToFilesText = t('mail', 'Go to Files') + + showSuccess(`
${escapeHtml(savedText)}