mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 03:29:20 +03:00
Resolve #342
This commit is contained in:
parent
a45cd5904f
commit
7da5692865
11 changed files with 115 additions and 56 deletions
32
dev/Model/MimeHeaderAutocrypt.js
Normal file
32
dev/Model/MimeHeaderAutocrypt.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
export class MimeHeaderAutocryptModel/* extends AbstractModel*/
|
||||
{
|
||||
constructor(value) {
|
||||
// super();
|
||||
this.addr = '';
|
||||
this.prefer_encrypt = 'nopreference', // nopreference or mutual
|
||||
this.keydata = '';
|
||||
|
||||
if (value) {
|
||||
value.split(';').forEach(entry => {
|
||||
entry = entry.split('=');
|
||||
const trim = str => (str || '').trim().replace(/^["']|["']+$/g, '');
|
||||
this[trim(entry[0]).replace('-', '_')] = trim(entry[1]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
if ('mutual' === this.prefer_encrypt) {
|
||||
return `addr=${this.addr}; prefer-encrypt=mutual; keydata=${this.keydata}`;
|
||||
}
|
||||
return `addr=${this.addr}; keydata=${this.keydata}`;
|
||||
}
|
||||
|
||||
key() {
|
||||
return '-----BEGIN PGP PUBLIC KEY BLOCK-----\n\n'
|
||||
+ this.keydata
|
||||
+ '\n-----END PGP PUBLIC KEY BLOCK-----';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue