Some more changes for #600

This commit is contained in:
the-djmaze 2022-11-01 19:14:08 +01:00
parent 41df46dbed
commit b39d023241
2 changed files with 17 additions and 12 deletions

View file

@ -15,9 +15,10 @@ const
askPassphrase = async (privateKey, btnTxt = 'LABEL_SIGN') =>
await AskPopupView.password('GnuPG key<br>' + privateKey.id + ' ' + privateKey.emails[0], 'OPENPGP/'+btnTxt),
findGnuPGKey = (keys, query, sign) =>
findGnuPGKey = (keys, query/*, sign*/) =>
keys.find(key =>
key[sign ? 'can_sign' : 'can_decrypt']
// key[sign ? 'can_sign' : 'can_decrypt']
(key.can_sign || key.can_decrypt)
&& (key.emails.includes(query) || key.subkeys.find(key => query == key.keyid || query == key.fingerprint))
);

View file

@ -529,16 +529,18 @@ export class MailMessageView extends AbstractViewRight {
pgpDecrypt() {
const oMessage = currentMessage();
PgpUserStore.decrypt(oMessage).then(result => {
if (result?.data) {
oMessage.pgpDecrypted(true);
MimeToMessage(result.data, oMessage);
oMessage.html() ? oMessage.viewHtml() : oMessage.viewPlain();
if (result.signatures?.length) {
oMessage.pgpSigned(true);
oMessage.pgpVerified({
signatures: result.signatures,
success: !!result.signatures.length
});
if (result) {
if (result.data) {
oMessage.pgpDecrypted(true);
MimeToMessage(result.data, oMessage);
oMessage.html() ? oMessage.viewHtml() : oMessage.viewPlain();
if (result.signatures?.length) {
oMessage.pgpSigned(true);
oMessage.pgpVerified({
signatures: result.signatures,
success: !!result.signatures.length
});
}
}
} else {
// TODO: translate
@ -553,6 +555,8 @@ export class MailMessageView extends AbstractViewRight {
PgpUserStore.verify(oMessage).then(result => {
if (result) {
oMessage.pgpVerified(result);
} else {
alert('Verification failed or no valid public key found');
}
/*
if (result?.success) {