mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
IdentityModel extends EmailModel
This commit is contained in:
parent
b01072e2e3
commit
f0b3d798bc
6 changed files with 27 additions and 21 deletions
|
|
@ -73,4 +73,9 @@ export class EmailModel extends AbstractModel {
|
||||||
}
|
}
|
||||||
return result || name;
|
return result || name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get domain() {
|
||||||
|
return this.email.replace(/^.+@([^@]+)$/, '$1');
|
||||||
|
// return this.email.slice(this.email.lastIndexOf('@'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
//import { AbstractModel } from 'Knoin/AbstractModel';
|
||||||
|
import { EmailModel } from 'Model/Email';
|
||||||
import { addObservablesTo, addComputablesTo } from 'External/ko';
|
import { addObservablesTo, addComputablesTo } from 'External/ko';
|
||||||
|
|
||||||
export class IdentityModel extends AbstractModel {
|
export class IdentityModel extends EmailModel /*AbstractModel*/ {
|
||||||
/**
|
/**
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @param {string} email
|
* @param {string} email
|
||||||
|
|
@ -12,8 +13,8 @@ export class IdentityModel extends AbstractModel {
|
||||||
addObservablesTo(this, {
|
addObservablesTo(this, {
|
||||||
id: '',
|
id: '',
|
||||||
label: '',
|
label: '',
|
||||||
email: '',
|
// email: '',
|
||||||
name: '',
|
// name: '',
|
||||||
|
|
||||||
replyTo: '',
|
replyTo: '',
|
||||||
bcc: '',
|
bcc: '',
|
||||||
|
|
@ -44,8 +45,8 @@ export class IdentityModel extends AbstractModel {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
formattedName() {
|
formattedName() {
|
||||||
const name = this.name(),
|
const name = this.name,
|
||||||
email = this.email(),
|
email = this.email,
|
||||||
label = this.label();
|
label = this.label();
|
||||||
return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : '');
|
return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : '');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ const
|
||||||
|
|
||||||
findIdentity = addresses => {
|
findIdentity = addresses => {
|
||||||
addresses = addresses.map(item => item.email);
|
addresses = addresses.map(item => item.email);
|
||||||
return IdentityUserStore.find(item => addresses.includes(item.email()));
|
return IdentityUserStore.find(item => addresses.includes(item.email));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -873,8 +873,8 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
identity = identity || IdentityUserStore()[0];
|
identity = identity || IdentityUserStore()[0];
|
||||||
if (identity) {
|
if (identity) {
|
||||||
// excludeEmail.add(identity.email());
|
// excludeEmail.add(identity.email);
|
||||||
excludeEmail[identity.email()] = true;
|
excludeEmail[identity.email] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arrayLength(options.to)) {
|
if (arrayLength(options.to)) {
|
||||||
|
|
@ -1381,7 +1381,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
allRecipients() {
|
allRecipients() {
|
||||||
return [
|
return [
|
||||||
// From/sender is also recipient (Sent mailbox)
|
// From/sender is also recipient (Sent mailbox)
|
||||||
// this.currentIdentity().email(),
|
// this.currentIdentity().email,
|
||||||
this.from(),
|
this.from(),
|
||||||
this.to(),
|
this.to(),
|
||||||
this.cc(),
|
this.cc(),
|
||||||
|
|
@ -1401,7 +1401,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
key && options.push(['OpenPGP', key]);
|
key && options.push(['OpenPGP', key]);
|
||||||
key = GnuPGUserStore.getPrivateKeyFor(email, 1);
|
key = GnuPGUserStore.getPrivateKeyFor(email, 1);
|
||||||
key && options.push(['GnuPG', key]);
|
key && options.push(['GnuPG', key]);
|
||||||
identity.smimeKeyValid() && identity.smimeCertificateValid() && identity.email() === email
|
identity.smimeKeyValid() && identity.smimeCertificateValid() && identity.email === email
|
||||||
&& options.push(['S/MIME']);
|
&& options.push(['S/MIME']);
|
||||||
console.dir({signOptions: options});
|
console.dir({signOptions: options});
|
||||||
this.signOptions(options);
|
this.signOptions(options);
|
||||||
|
|
@ -1420,7 +1420,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
|
|
||||||
const count = recipients.length,
|
const count = recipients.length,
|
||||||
identity = this.currentIdentity(),
|
identity = this.currentIdentity(),
|
||||||
from = (identity.smimeKey() && identity.smimeCertificate()) ? identity.email() : null;
|
from = (identity.smimeKey() && identity.smimeCertificate()) ? identity.email : null;
|
||||||
count
|
count
|
||||||
&& count === recipients.filter(email =>
|
&& count === recipients.filter(email =>
|
||||||
email == from
|
email == from
|
||||||
|
|
@ -1497,7 +1497,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
**/
|
**/
|
||||||
linkedData: []
|
linkedData: []
|
||||||
},
|
},
|
||||||
recipients = draft ? [identity.email()] : this.allRecipients(),
|
recipients = draft ? [identity.email] : this.allRecipients(),
|
||||||
signOptions = !draft && this.doSign() && this.signOptions(),
|
signOptions = !draft && this.doSign() && this.signOptions(),
|
||||||
encryptOptions = this.doEncrypt() && this.encryptOptions(),
|
encryptOptions = this.doEncrypt() && this.encryptOptions(),
|
||||||
isHtml = this.oEditor.isHtml();
|
isHtml = this.oEditor.isHtml();
|
||||||
|
|
@ -1593,7 +1593,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
// params.attachCertificate = false;
|
// params.attachCertificate = false;
|
||||||
if (identity.smimeKeyEncrypted()) {
|
if (identity.smimeKeyEncrypted()) {
|
||||||
const pass = await Passphrases.ask(identity,
|
const pass = await Passphrases.ask(identity,
|
||||||
i18n('SMIME/PRIVATE_KEY_OF', {EMAIL: identity.email()}),
|
i18n('SMIME/PRIVATE_KEY_OF', {EMAIL: identity.email}),
|
||||||
'CRYPTO/SIGN'
|
'CRYPTO/SIGN'
|
||||||
);
|
);
|
||||||
if (null != pass) {
|
if (null != pass) {
|
||||||
|
|
@ -1633,7 +1633,7 @@ export class ComposePopupView extends AbstractViewPopup {
|
||||||
if ('S/MIME' == encryptOptions[i]) {
|
if ('S/MIME' == encryptOptions[i]) {
|
||||||
params.encryptCertificates = [identity.smimeCertificate()];
|
params.encryptCertificates = [identity.smimeCertificate()];
|
||||||
SMimeUserStore.forEach(certificate => {
|
SMimeUserStore.forEach(certificate => {
|
||||||
certificate.emailAddress != identity.email()
|
certificate.emailAddress != identity.email
|
||||||
&& recipients.includes(certificate.emailAddress)
|
&& recipients.includes(certificate.emailAddress)
|
||||||
&& params.encryptCertificates.push(certificate.id)
|
&& params.encryptCertificates.push(certificate.id)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,8 @@ export class IdentityPopupView extends AbstractViewPopup {
|
||||||
this.submitError(oData.message);
|
this.submitError(oData.message);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: identity.name(),
|
name: identity.name,
|
||||||
email: identity.email(),
|
email: identity.email,
|
||||||
privateKey: identity.smimeKey(),
|
privateKey: identity.smimeKey(),
|
||||||
passphrase: result.password
|
passphrase: result.password
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,9 @@ export class OpenPgpGeneratePopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow() {
|
onShow() {
|
||||||
this.name(''/*IdentityUserStore()[0].name()*/);
|
this.name(''/*IdentityUserStore()[0].name*/);
|
||||||
this.password('');
|
this.password('');
|
||||||
this.email(''/*IdentityUserStore()[0].email()*/);
|
this.email(''/*IdentityUserStore()[0].email*/);
|
||||||
this.emailError(false);
|
this.emailError(false);
|
||||||
this.submitError('');
|
this.submitError('');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -670,7 +670,7 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
async smimeDecrypt() {
|
async smimeDecrypt() {
|
||||||
const message = currentMessage();
|
const message = currentMessage();
|
||||||
const addresses = message.from.concat(message.to, message.cc, message.bcc).map(item => item.email),
|
const addresses = message.from.concat(message.to, message.cc, message.bcc).map(item => item.email),
|
||||||
identity = IdentityUserStore.find(item => addresses.includes(item.email())),
|
identity = IdentityUserStore.find(item => addresses.includes(item.email)),
|
||||||
data = message.smimeEncrypted(); // { partId: "1" }
|
data = message.smimeEncrypted(); // { partId: "1" }
|
||||||
if (data && identity) {
|
if (data && identity) {
|
||||||
delete data.error;
|
delete data.error;
|
||||||
|
|
@ -682,7 +682,7 @@ export class MailMessageView extends AbstractViewRight {
|
||||||
params.privateKey = identity.smimeKey();
|
params.privateKey = identity.smimeKey();
|
||||||
if (identity.smimeKeyEncrypted()) {
|
if (identity.smimeKeyEncrypted()) {
|
||||||
pass = await Passphrases.ask(identity,
|
pass = await Passphrases.ask(identity,
|
||||||
i18n('SMIME/PRIVATE_KEY_OF', {EMAIL: identity.email()}),
|
i18n('SMIME/PRIVATE_KEY_OF', {EMAIL: identity.email}),
|
||||||
'CRYPTO/DECRYPT'
|
'CRYPTO/DECRYPT'
|
||||||
);
|
);
|
||||||
if (!pass) {
|
if (!pass) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue