From 6f63c1686e345939237849fdb4bb67783be16a3a Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 3 Aug 2023 10:16:35 -0600 Subject: [PATCH] * Mail: Add attachment action "Forward to" that adds file directly to compose window --- mail/js/app.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/mail/js/app.js b/mail/js/app.js index 3aaa6f8eb8..83b3c84dc7 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -1224,6 +1224,12 @@ app.classes.mail = AppJS.extend( label: 'Save as ZIP', icon: 'mail/save_zip', value: 'downloadAllToZip' + }, + { + id: 'forward', + label: 'Forward to', + icon: 'mail/forward', + value: 'forward' } ]; const collabora = { @@ -3299,6 +3305,35 @@ app.classes.mail = AppJS.extend( }); this.et2._inst.download(url); break; + case 'forward': + // Give some UI feedback, this might take a second + document.body.style.cursor = 'wait'; + + // Move the attachment to VFS + const file_id = mail_id+'::'+attachments[row_id].partID+'::'+attachments[row_id].winmailFlag+'::'+attachments[row_id].filename; + this.egw.request("mail.mail_ui.ajax_vfsOpen", [file_id,attachments[row_id].filename]) + .then((vfs_path) => { + if(!vfs_path) + { + // Server call will also display an error on failure + return; + } + + // File is in VFS, put it in a compose window + const params = {}; + let content = {data:{files:{file:[]}}}; + params['preset[file][]'] = 'vfs://default'+vfs_path; + content.data.files.file.push('vfs://default'+vfs_path); + content.data.files["filemode"] = params['preset[filemode]']; + // always open compose in html mode, as attachment links look a lot nicer in html + params["mimeType"] = 'html'; + egw.openWithinWindow("mail", "setCompose", content, params, /mail.mail_compose.compose/, true); + }) + .finally(() => { + // No matter what, clear the waiting style + document.body.style.cursor = ''; + }); + break; } },