mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-14 17:14:30 +08:00
#89 added downloading of decrypted attachments
This commit is contained in:
parent
4a1c3beb78
commit
25a786d584
5 changed files with 36 additions and 30 deletions
|
@ -18,7 +18,6 @@ import {
|
|||
import {
|
||||
doc,
|
||||
elementById,
|
||||
createElement,
|
||||
$htmlCL,
|
||||
Settings,
|
||||
SettingsGet,
|
||||
|
@ -546,23 +545,6 @@ class AppUser extends AbstractApp {
|
|||
}, query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} link
|
||||
* @returns {boolean}
|
||||
*/
|
||||
download(link) {
|
||||
if (ThemeStore.isMobile()) {
|
||||
open(link, '_self');
|
||||
focus();
|
||||
} else {
|
||||
const oLink = createElement('a');
|
||||
oLink.href = link;
|
||||
doc.body.appendChild(oLink).click();
|
||||
oLink.remove();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
logout() {
|
||||
Remote.request('Logout', () => rl.logoutReload());
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { ComposeType/*, FolderType*/ } from 'Common/EnumsUser';
|
||||
import { EmailModel } from 'Model/Email';
|
||||
import { isArray } from 'Common/Utils';
|
||||
import { createElement } from 'Common/Globals';
|
||||
import { doc, createElement } from 'Common/Globals';
|
||||
import { FolderUserStore } from 'Stores/User/Folder';
|
||||
import { SettingsUserStore } from 'Stores/User/Settings';
|
||||
import * as Local from 'Storage/Client';
|
||||
import { plainToHtml } from 'Common/Html';
|
||||
import { ThemeStore } from 'Stores/Theme';
|
||||
|
||||
export const
|
||||
|
||||
|
@ -20,6 +21,24 @@ sortFolders = folders => {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} link
|
||||
* @returns {boolean}
|
||||
*/
|
||||
download = (link, name = "") => {
|
||||
if (ThemeStore.isMobile()) {
|
||||
open(link, '_self');
|
||||
focus();
|
||||
} else {
|
||||
const oLink = createElement('a');
|
||||
oLink.href = link;
|
||||
oLink.target = '_blank';
|
||||
oLink.download = name;
|
||||
doc.body.appendChild(oLink).click();
|
||||
oLink.remove();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Array=} aDisabled
|
||||
* @param {Array=} aHeaderLines
|
||||
|
|
|
@ -21,7 +21,6 @@ export class AttachmentModel extends AbstractModel {
|
|||
this.fileNameExt = '';
|
||||
this.fileType = FileType.Unknown;
|
||||
this.friendlySize = '';
|
||||
this.isInline = false;
|
||||
this.isLinked = false;
|
||||
this.isThumbnail = false;
|
||||
this.cid = '';
|
||||
|
@ -29,8 +28,13 @@ export class AttachmentModel extends AbstractModel {
|
|||
this.download = '';
|
||||
this.folder = '';
|
||||
this.uid = '';
|
||||
this.url = '';
|
||||
this.mimeIndex = '';
|
||||
this.framed = false;
|
||||
|
||||
this.addObservables({
|
||||
isInline: false
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,14 +128,14 @@ export class AttachmentModel extends AbstractModel {
|
|||
* @returns {string}
|
||||
*/
|
||||
linkDownload() {
|
||||
return attachmentDownload(this.download);
|
||||
return this.url || attachmentDownload(this.download);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
linkPreview() {
|
||||
return serverRequestRaw('View', this.download);
|
||||
return this.url || serverRequestRaw('View', this.download);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
import { ComposeType } from 'Common/EnumsUser';
|
||||
|
||||
import { arrayLength, pInt } from 'Common/Utils';
|
||||
import { delegateRunOnDestroy, computedPaginatorHelper, showMessageComposer } from 'Common/UtilsUser';
|
||||
import { download, delegateRunOnDestroy, computedPaginatorHelper, showMessageComposer } from 'Common/UtilsUser';
|
||||
|
||||
import { Selector } from 'Common/Selector';
|
||||
import { serverRequestRaw, serverRequest } from 'Common/Links';
|
||||
|
@ -317,11 +317,11 @@ class ContactsPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
exportVcf() {
|
||||
rl.app.download(serverRequestRaw('ContactsVcf'));
|
||||
download(serverRequestRaw('ContactsVcf'), 'contacts.vcf');
|
||||
}
|
||||
|
||||
exportCsv() {
|
||||
rl.app.download(serverRequestRaw('ContactsCsv'));
|
||||
download(serverRequestRaw('ContactsCsv'), 'contacts.csv');
|
||||
}
|
||||
|
||||
removeCheckedOrSelectedContactsFromList() {
|
||||
|
|
|
@ -27,7 +27,7 @@ import {
|
|||
} from 'Common/Globals';
|
||||
|
||||
import { arrayLength, inFocus } from 'Common/Utils';
|
||||
import { mailToHelper, showMessageComposer, initFullscreen } from 'Common/UtilsUser';
|
||||
import { download, mailToHelper, showMessageComposer, initFullscreen } from 'Common/UtilsUser';
|
||||
|
||||
import { SMAudio } from 'Common/Audio';
|
||||
|
||||
|
@ -95,7 +95,7 @@ const
|
|||
attachment.cid = cid ? cid.value : '';
|
||||
if (cid && html) {
|
||||
let cid = 'cid:' + attachment.contentId();
|
||||
attachment.isInline = html.includes(cid);
|
||||
attachment.isInline(html.includes(cid));
|
||||
html = html
|
||||
.replace('src="' + cid + '"', 'src="' + attachment.url + '"')
|
||||
.replace("src='" + cid + "'", "src='" + attachment.url + "'");
|
||||
|
@ -379,7 +379,7 @@ export class MailMessageView extends AbstractViewRight {
|
|||
el = eqs(event, '.attachmentsPlace .attachmentItem .attachmentNameParent');
|
||||
if (el) {
|
||||
const attachment = ko.dataFor(el);
|
||||
attachment && attachment.download && rl.app.download(attachment.linkDownload());
|
||||
attachment && attachment.linkDownload() && download(attachment.linkDownload(), attachment.fileName);
|
||||
}
|
||||
|
||||
if (eqs(event, '.messageItemHeader .subjectParent .flagParent')) {
|
||||
|
@ -587,8 +587,9 @@ export class MailMessageView extends AbstractViewRight {
|
|||
if (hashes.length) {
|
||||
Remote.attachmentsActions('Zip', hashes, this.downloadAsZipLoading)
|
||||
.then(result => {
|
||||
if (result && result.Result && result.Result.FileHash) {
|
||||
rl.app.download(attachmentDownload(result.Result.FileHash));
|
||||
let hash = result && result.Result && result.Result.FileHash;
|
||||
if (hash) {
|
||||
download(attachmentDownload(hash), hash+'.zip');
|
||||
} else {
|
||||
this.downloadAsZipError(true);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue