2019-07-05 03:19:24 +08:00
|
|
|
import { AbstractModel } from 'Knoin/AbstractModel';
|
2024-02-21 01:29:35 +08:00
|
|
|
import { addObservablesTo, addComputablesTo } from 'External/ko';
|
2016-07-07 05:03:30 +08:00
|
|
|
|
2021-01-22 23:32:08 +08:00
|
|
|
export class IdentityModel extends AbstractModel {
|
2016-07-07 05:03:30 +08:00
|
|
|
/**
|
|
|
|
* @param {string} id
|
|
|
|
* @param {string} email
|
|
|
|
*/
|
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: '',
|
2023-02-21 23:02:22 +08:00
|
|
|
email: '',
|
2020-10-25 18:46:58 +08:00
|
|
|
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: '',
|
|
|
|
|
2022-01-28 06:07:34 +08:00
|
|
|
askDelete: false
|
2020-10-25 18:46:58 +08:00
|
|
|
});
|
2024-02-21 01:29:35 +08:00
|
|
|
|
|
|
|
addComputablesTo(this, {
|
|
|
|
smimeKeyEncrypted: () => this.smimeKey().includes('-----BEGIN ENCRYPTED PRIVATE KEY-----')
|
|
|
|
// smimeKeyValid: () => this.smimeKeyEncrypted() | this.smimeKey().includes('-----BEGIN PRIVATE KEY-----')
|
|
|
|
// smimeCertificateValid: () => this.smimeKey().includes('-----BEGIN CERTIFICATE-----')
|
|
|
|
});
|
2016-07-07 05:03:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
formattedName() {
|
2019-07-05 03:19:24 +08:00
|
|
|
const name = this.name(),
|
2024-02-09 09:39:00 +08:00
|
|
|
email = this.email(),
|
|
|
|
label = this.label();
|
|
|
|
return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : '');
|
2016-07-07 05:03:30 +08:00
|
|
|
}
|
|
|
|
}
|