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