From d8b05ee361c92440f4859eae708b095fdaa6f590 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sat, 25 Feb 2023 14:16:04 +0100 Subject: [PATCH] Resolve #992 --- dev/Common/UtilsUser.js | 3 ++- dev/View/User/MailBox/MessageList.js | 10 ++++++++-- dev/View/User/MailBox/MessageView.js | 4 +++- .../app/libraries/RainLoop/Actions/Attachments.php | 3 ++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dev/Common/UtilsUser.js b/dev/Common/UtilsUser.js index 407d081c6..ed2bed58f 100644 --- a/dev/Common/UtilsUser.js +++ b/dev/Common/UtilsUser.js @@ -42,10 +42,11 @@ download = (link, name = "") => { } }, -downloadZip = (hashes, onError, fTrigger, folder) => { +downloadZip = (name, hashes, onError, fTrigger, folder) => { if (hashes.length) { let params = { target: 'zip', + filename: name, hashes: hashes }; if (!onError) { diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index bfcee8f86..fda67d58f 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -363,13 +363,19 @@ export class MailMessageList extends AbstractViewRight { ]); } + /** + * Download selected messages + */ downloadZipCommand() { let hashes = []/*, uids = []*/; // MessagelistUserStore.forEach(message => message.checked() && uids.push(message.uid)); MessagelistUserStore.forEach(message => message.checked() && hashes.push(message.requestHash)); - downloadZip(hashes, null, null, MessagelistUserStore().folder); + downloadZip(null, hashes, null, null, MessagelistUserStore().folder); } + /** + * Download attachments of selected messages + */ downloadAttachCommand() { let hashes = []; MessagelistUserStore.forEach(message => { @@ -381,7 +387,7 @@ export class MailMessageList extends AbstractViewRight { }); } }); - downloadZip(hashes); + downloadZip(null, hashes); } deleteWithoutMoveCommand() { diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 766869935..759084172 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -469,7 +469,9 @@ export class MailMessageView extends AbstractViewRight { const hashes = (currentMessage()?.attachments || []) .map(item => item?.checked() /*&& !item?.isLinked()*/ ? item.download : '') .filter(v => v); - downloadZip(hashes, + downloadZip( + currentMessage().subject(), + hashes, () => this.downloadAsZipError(true), this.downloadAsZipLoading ); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Attachments.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Attachments.php index 32baab49d..44ce9969f 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Attachments.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Attachments.php @@ -14,6 +14,7 @@ trait Attachments { $sAction = $this->GetActionParam('target', ''); $sFolder = $this->GetActionParam('folder', ''); + $sFilename = \MailSo\Base\Utils::SecureFileName($this->GetActionParam('filename', '')); $aHashes = $this->GetActionParam('hashes', null); $oFilesProvider = $this->FilesProvider(); if (empty($sAction) || !$this->GetCapa(Capa::ATTACHMENTS_ACTIONS) || !$oFilesProvider || !$oFilesProvider->IsActive()) { @@ -108,7 +109,7 @@ trait Attachments if (!$bError) { $mResult = array( 'fileHash' => $this->encodeRawKey($oAccount, array( - 'fileName' => ($sFolder ? 'messages' : 'attachments') . \date('-YmdHis') . '.zip', + 'fileName' => ($sFilename ?: ($sFolder ? 'messages' : 'attachments')) . \date('-YmdHis') . '.zip', 'mimeType' => 'application/zip', 'fileHash' => $sZipHash ))