mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 13:39:22 +03:00
#89 Composer move sign/encrypt buttons from menu to view
This commit is contained in:
parent
26d3509e28
commit
5b051745fe
6 changed files with 152 additions and 174 deletions
|
|
@ -133,13 +133,13 @@ export const GnuPGUserStore = new class {
|
|||
/**
|
||||
* Checks if verifying/encrypting a message is possible with given email addresses.
|
||||
*/
|
||||
hasPublicKeyForEmails(recipients, all) {
|
||||
hasPublicKeyForEmails(recipients) {
|
||||
const count = recipients.length,
|
||||
length = count ? recipients.filter(email =>
|
||||
// (key.can_verify || key.can_encrypt) &&
|
||||
this.publicKeys.find(key => key.emails.includes(email))
|
||||
).length : 0;
|
||||
return length && (!all || length === count);
|
||||
return length && length === count;
|
||||
}
|
||||
|
||||
getPrivateKeyFor(query, sign) {
|
||||
|
|
|
|||
|
|
@ -145,12 +145,12 @@ export const OpenPGPUserStore = new class {
|
|||
/**
|
||||
* Checks if verifying/encrypting a message is possible with given email addresses.
|
||||
*/
|
||||
hasPublicKeyForEmails(recipients, all) {
|
||||
hasPublicKeyForEmails(recipients) {
|
||||
const count = recipients.length,
|
||||
length = count ? recipients.filter(email =>
|
||||
this.publicKeys().find(key => key.emails.includes(email))
|
||||
).length : 0;
|
||||
return length && (!all || length === count);
|
||||
return length && length === count;
|
||||
}
|
||||
|
||||
getPrivateKeyFor(query/*, sign*/) {
|
||||
|
|
|
|||
|
|
@ -74,33 +74,28 @@ export const PgpUserStore = new class {
|
|||
return 0 === text.trim().indexOf('-----BEGIN PGP MESSAGE-----');
|
||||
}
|
||||
|
||||
async mailvelopeHasPublicKeyForEmails(recipients, all) {
|
||||
async mailvelopeHasPublicKeyForEmails(recipients) {
|
||||
const
|
||||
keyring = this.mailvelopeKeyring,
|
||||
mailvelope = keyring && await keyring.validKeyForAddress(recipients)
|
||||
/*.then(LookupResult => Object.entries(LookupResult))*/,
|
||||
entries = mailvelope && Object.entries(mailvelope);
|
||||
return !!(entries && (all ? (entries.filter(value => value[1]).length === recipients.length) : entries.length));
|
||||
return entries && entries.filter(value => value[1]).length === recipients.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if verifying/encrypting a message is possible with given email addresses.
|
||||
* Returns the first library that can.
|
||||
*/
|
||||
async hasPublicKeyForEmails(recipients, all) {
|
||||
async hasPublicKeyForEmails(recipients) {
|
||||
const count = recipients.length;
|
||||
if (count) {
|
||||
if (OpenPGPUserStore.hasPublicKeyForEmails(recipients, all)) {
|
||||
if (OpenPGPUserStore.hasPublicKeyForEmails(recipients)) {
|
||||
return 'openpgp';
|
||||
}
|
||||
|
||||
if (GnuPGUserStore.hasPublicKeyForEmails(recipients, all)) {
|
||||
if (GnuPGUserStore.hasPublicKeyForEmails(recipients)) {
|
||||
return 'gnupg';
|
||||
}
|
||||
|
||||
if (await this.mailvelopeHasPublicKeyForEmails(recipients, all)) {
|
||||
return 'mailvelope';
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue