2024-10-23 06:56:42 +08:00
|
|
|
//import { AbstractModel } from 'Knoin/AbstractModel';
|
|
|
|
import { EmailModel } from 'Model/Email';
|
2024-02-21 01:29:35 +08:00
|
|
|
import { addObservablesTo, addComputablesTo } from 'External/ko';
|
2016-07-07 05:03:30 +08:00
|
|
|
|
2024-10-23 06:56:42 +08:00
|
|
|
export class IdentityModel extends EmailModel /*AbstractModel*/ {
|
2023-02-21 23:02:22 +08:00
|
|
|
constructor() {
|
2020-10-19 01:19:45 +08:00
|
|
|
super();
|
2016-07-07 05:03:30 +08:00
|
|
|
|
2022-10-31 05:19:52 +08:00
|
|
|
addObservablesTo(this, {
|
2023-02-21 23:02:22 +08:00
|
|
|
id: '',
|
2024-02-09 09:39:00 +08:00
|
|
|
label: '',
|
2024-10-23 06:56:42 +08:00
|
|
|
// email: '',
|
|
|
|
// name: '',
|
2016-07-07 05:03:30 +08:00
|
|
|
|
2020-10-25 18:46:58 +08:00
|
|
|
replyTo: '',
|
|
|
|
bcc: '',
|
2024-02-12 09:13:39 +08:00
|
|
|
sentFolder: '',
|
2016-07-07 05:03:30 +08:00
|
|
|
|
2020-10-25 18:46:58 +08:00
|
|
|
signature: '',
|
|
|
|
signatureInsertBefore: false,
|
|
|
|
|
2024-02-12 04:16:38 +08:00
|
|
|
pgpSign: false,
|
|
|
|
pgpEncrypt: false,
|
|
|
|
|
2024-02-19 00:18:47 +08:00
|
|
|
smimeKey: '',
|
|
|
|
smimeCertificate: '',
|
|
|
|
|
2024-08-06 23:50:43 +08:00
|
|
|
askDelete: false,
|
|
|
|
|
|
|
|
exists: false
|
2020-10-25 18:46:58 +08:00
|
|
|
});
|
2024-02-21 01:29:35 +08:00
|
|
|
|
|
|
|
addComputablesTo(this, {
|
2024-03-01 09:08:29 +08:00
|
|
|
smimeKeyEncrypted: () => this.smimeKey().includes('-----BEGIN ENCRYPTED PRIVATE KEY-----'),
|
2024-03-19 00:17:25 +08:00
|
|
|
smimeKeyValid: () => /^-----BEGIN (ENCRYPTED |RSA )?PRIVATE KEY-----/.test(this.smimeKey()),
|
2024-03-01 09:08:29 +08:00
|
|
|
smimeCertificateValid: () => /^-----BEGIN CERTIFICATE-----/.test(this.smimeCertificate())
|
2024-02-21 01:29:35 +08:00
|
|
|
});
|
2016-07-07 05:03:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
2024-10-28 19:01:59 +08:00
|
|
|
toString() {
|
2024-10-23 06:56:42 +08:00
|
|
|
const name = this.name,
|
|
|
|
email = this.email,
|
2024-02-09 09:39:00 +08:00
|
|
|
label = this.label();
|
|
|
|
return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : '');
|
2016-07-07 05:03:30 +08:00
|
|
|
}
|
|
|
|
}
|