mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 00:47:04 +03: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 {
|
import {
|
||||||
doc,
|
doc,
|
||||||
elementById,
|
elementById,
|
||||||
createElement,
|
|
||||||
$htmlCL,
|
$htmlCL,
|
||||||
Settings,
|
Settings,
|
||||||
SettingsGet,
|
SettingsGet,
|
||||||
|
|
@ -546,23 +545,6 @@ class AppUser extends AbstractApp {
|
||||||
}, query);
|
}, 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() {
|
logout() {
|
||||||
Remote.request('Logout', () => rl.logoutReload());
|
Remote.request('Logout', () => rl.logoutReload());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import { ComposeType/*, FolderType*/ } from 'Common/EnumsUser';
|
import { ComposeType/*, FolderType*/ } from 'Common/EnumsUser';
|
||||||
import { EmailModel } from 'Model/Email';
|
import { EmailModel } from 'Model/Email';
|
||||||
import { isArray } from 'Common/Utils';
|
import { isArray } from 'Common/Utils';
|
||||||
import { createElement } from 'Common/Globals';
|
import { doc, createElement } from 'Common/Globals';
|
||||||
import { FolderUserStore } from 'Stores/User/Folder';
|
import { FolderUserStore } from 'Stores/User/Folder';
|
||||||
import { SettingsUserStore } from 'Stores/User/Settings';
|
import { SettingsUserStore } from 'Stores/User/Settings';
|
||||||
import * as Local from 'Storage/Client';
|
import * as Local from 'Storage/Client';
|
||||||
import { plainToHtml } from 'Common/Html';
|
import { plainToHtml } from 'Common/Html';
|
||||||
|
import { ThemeStore } from 'Stores/Theme';
|
||||||
|
|
||||||
export const
|
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=} aDisabled
|
||||||
* @param {Array=} aHeaderLines
|
* @param {Array=} aHeaderLines
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ export class AttachmentModel extends AbstractModel {
|
||||||
this.fileNameExt = '';
|
this.fileNameExt = '';
|
||||||
this.fileType = FileType.Unknown;
|
this.fileType = FileType.Unknown;
|
||||||
this.friendlySize = '';
|
this.friendlySize = '';
|
||||||
this.isInline = false;
|
|
||||||
this.isLinked = false;
|
this.isLinked = false;
|
||||||
this.isThumbnail = false;
|
this.isThumbnail = false;
|
||||||
this.cid = '';
|
this.cid = '';
|
||||||
|
|
@ -29,8 +28,13 @@ export class AttachmentModel extends AbstractModel {
|
||||||
this.download = '';
|
this.download = '';
|
||||||
this.folder = '';
|
this.folder = '';
|
||||||
this.uid = '';
|
this.uid = '';
|
||||||
|
this.url = '';
|
||||||
this.mimeIndex = '';
|
this.mimeIndex = '';
|
||||||
this.framed = false;
|
this.framed = false;
|
||||||
|
|
||||||
|
this.addObservables({
|
||||||
|
isInline: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,14 +128,14 @@ export class AttachmentModel extends AbstractModel {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
linkDownload() {
|
linkDownload() {
|
||||||
return attachmentDownload(this.download);
|
return this.url || attachmentDownload(this.download);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
linkPreview() {
|
linkPreview() {
|
||||||
return serverRequestRaw('View', this.download);
|
return this.url || serverRequestRaw('View', this.download);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
import { ComposeType } from 'Common/EnumsUser';
|
import { ComposeType } from 'Common/EnumsUser';
|
||||||
|
|
||||||
import { arrayLength, pInt } from 'Common/Utils';
|
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 { Selector } from 'Common/Selector';
|
||||||
import { serverRequestRaw, serverRequest } from 'Common/Links';
|
import { serverRequestRaw, serverRequest } from 'Common/Links';
|
||||||
|
|
@ -317,11 +317,11 @@ class ContactsPopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
exportVcf() {
|
exportVcf() {
|
||||||
rl.app.download(serverRequestRaw('ContactsVcf'));
|
download(serverRequestRaw('ContactsVcf'), 'contacts.vcf');
|
||||||
}
|
}
|
||||||
|
|
||||||
exportCsv() {
|
exportCsv() {
|
||||||
rl.app.download(serverRequestRaw('ContactsCsv'));
|
download(serverRequestRaw('ContactsCsv'), 'contacts.csv');
|
||||||
}
|
}
|
||||||
|
|
||||||
removeCheckedOrSelectedContactsFromList() {
|
removeCheckedOrSelectedContactsFromList() {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import {
|
||||||
} from 'Common/Globals';
|
} from 'Common/Globals';
|
||||||
|
|
||||||
import { arrayLength, inFocus } from 'Common/Utils';
|
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';
|
import { SMAudio } from 'Common/Audio';
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ const
|
||||||
attachment.cid = cid ? cid.value : '';
|
attachment.cid = cid ? cid.value : '';
|
||||||
if (cid && html) {
|
if (cid && html) {
|
||||||
let cid = 'cid:' + attachment.contentId();
|
let cid = 'cid:' + attachment.contentId();
|
||||||
attachment.isInline = html.includes(cid);
|
attachment.isInline(html.includes(cid));
|
||||||
html = html
|
html = html
|
||||||
.replace('src="' + cid + '"', 'src="' + attachment.url + '"')
|
.replace('src="' + cid + '"', 'src="' + attachment.url + '"')
|
||||||
.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');
|
el = eqs(event, '.attachmentsPlace .attachmentItem .attachmentNameParent');
|
||||||
if (el) {
|
if (el) {
|
||||||
const attachment = ko.dataFor(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')) {
|
if (eqs(event, '.messageItemHeader .subjectParent .flagParent')) {
|
||||||
|
|
@ -587,8 +587,9 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
if (hashes.length) {
|
if (hashes.length) {
|
||||||
Remote.attachmentsActions('Zip', hashes, this.downloadAsZipLoading)
|
Remote.attachmentsActions('Zip', hashes, this.downloadAsZipLoading)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result && result.Result && result.Result.FileHash) {
|
let hash = result && result.Result && result.Result.FileHash;
|
||||||
rl.app.download(attachmentDownload(result.Result.FileHash));
|
if (hash) {
|
||||||
|
download(attachmentDownload(hash), hash+'.zip');
|
||||||
} else {
|
} else {
|
||||||
this.downloadAsZipError(true);
|
this.downloadAsZipError(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue