Skip to content

Commit

Permalink
Resolve #992
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Feb 25, 2023
1 parent 0144be4 commit d8b05ee
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion dev/Common/UtilsUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions dev/View/User/MailBox/MessageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -381,7 +387,7 @@ export class MailMessageList extends AbstractViewRight {
});
}
});
downloadZip(hashes);
downloadZip(null, hashes);
}

deleteWithoutMoveCommand() {
Expand Down
4 changes: 3 additions & 1 deletion dev/View/User/MailBox/MessageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function DoAttachmentsActions() : array
{
$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()) {
Expand Down Expand Up @@ -108,7 +109,7 @@ public function DoAttachmentsActions() : array
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
))
Expand Down

0 comments on commit d8b05ee

Please sign in to comment.