This commit is contained in:
the-djmaze 2023-02-25 14:16:04 +01:00
parent 0144be49bf
commit d8b05ee361
4 changed files with 15 additions and 5 deletions

View file

@ -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) {

View file

@ -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() {

View file

@ -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
);

View file

@ -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
))