mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
mailToHelper() use URLSearchParams
This commit is contained in:
parent
4b8e77be5c
commit
ffcd9990eb
2 changed files with 28 additions and 49 deletions
|
|
@ -348,10 +348,7 @@ class AppUser extends AbstractApp {
|
||||||
);
|
);
|
||||||
} catch (e) {} // eslint-disable-line no-empty
|
} catch (e) {} // eslint-disable-line no-empty
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => mailToHelper(SettingsGet('MailToEmail')), 500);
|
||||||
value = SettingsGet('MailToEmail');
|
|
||||||
value && mailToHelper(value);
|
|
||||||
}, 500);
|
|
||||||
} else {
|
} else {
|
||||||
this.logout();
|
this.logout();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,32 +123,21 @@ computedPaginatorHelper = (koCurrentPage, koPageCount) => {
|
||||||
* @param {string} mailToUrl
|
* @param {string} mailToUrl
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
mailToHelper = (mailToUrl) => {
|
mailToHelper = mailToUrl => {
|
||||||
if (
|
if (mailToUrl && 'mailto:' === mailToUrl.slice(0, 7).toLowerCase()) {
|
||||||
mailToUrl &&
|
mailToUrl = mailToUrl.slice(7).split('?');
|
||||||
'mailto:' ===
|
|
||||||
mailToUrl
|
|
||||||
.toString()
|
|
||||||
.slice(0, 7)
|
|
||||||
.toLowerCase()
|
|
||||||
) {
|
|
||||||
mailToUrl = mailToUrl.toString().slice(7);
|
|
||||||
|
|
||||||
let to = [],
|
const
|
||||||
params = {};
|
email = mailToUrl[0],
|
||||||
|
params = new URLSearchParams(mailToUrl[1]),
|
||||||
|
toEmailModel = value => null != value ? EmailModel.parseEmailLine(value) : null;
|
||||||
|
|
||||||
const email = mailToUrl.replace(/\?.+$/, ''),
|
showMessageComposer([
|
||||||
query = mailToUrl.replace(/^[^?]*\?/, ''),
|
ComposeType.Empty,
|
||||||
toEmailModel = value => null != value ? EmailModel.parseEmailLine(decodeURIComponent(value)) : null;
|
null,
|
||||||
|
params.get('to')
|
||||||
query.split('&').forEach(temp => {
|
? Object.values(
|
||||||
temp = temp.split('=');
|
toEmailModel(email + ',' + params.get('to')).reduce((result, value) => {
|
||||||
params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (null != params.to) {
|
|
||||||
to = Object.values(
|
|
||||||
toEmailModel(email + ',' + params.to).reduce((result, value) => {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
if (result[value.email]) {
|
if (result[value.email]) {
|
||||||
if (!result[value.email].name) {
|
if (!result[value.email].name) {
|
||||||
|
|
@ -160,19 +149,12 @@ mailToHelper = (mailToUrl) => {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}, {})
|
}, {})
|
||||||
);
|
)
|
||||||
} else {
|
: EmailModel.parseEmailLine(email),
|
||||||
to = EmailModel.parseEmailLine(email);
|
toEmailModel(params.get('cc')),
|
||||||
}
|
toEmailModel(params.get('bcc')),
|
||||||
|
params.get('subject'),
|
||||||
showMessageComposer([
|
plainToHtml(params.get('body') || '')
|
||||||
ComposeType.Empty,
|
|
||||||
null,
|
|
||||||
to,
|
|
||||||
toEmailModel(params.cc),
|
|
||||||
toEmailModel(params.bcc),
|
|
||||||
null == params.subject ? null : decodeURIComponent(params.subject),
|
|
||||||
null == params.body ? null : plainToHtml(decodeURIComponent(params.body))
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue