diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-12-20 13:25:35 -0600 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-06 23:57:08 +0100 |
commit | 2af81a7430481b3aec40f6a794db8cde4e1e18e4 (patch) | |
tree | 3d6d298d50f34cf453b2214da94a273f63d061c3 /widgets/compose.go | |
parent | 915b869e3fc6377be114c033763987de612c443c (diff) | |
download | aerc-2af81a7430481b3aec40f6a794db8cde4e1e18e4.tar.gz |
pgp: add configurable error level for opportunistic encryption
Add a user-configurable error level for when opportunistic encryption is
enabled but the message cannot be encrypted. Set the default level to
this as "warn". This config option *only* applies when opportunistic
encryption is enabled. If a user tries to manually encrypt a message,
an error will still be shown.
Don't show encryption status until at least one recipient is added.
Fixes: https://todo.sr.ht/~rjarry/aerc/95
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/compose.go')
-rw-r--r-- | widgets/compose.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/widgets/compose.go b/widgets/compose.go index 1a59bd3a..aad566f5 100644 --- a/widgets/compose.go +++ b/widgets/compose.go @@ -1483,11 +1483,25 @@ func (c *Composer) checkEncryptionKeys(_ string) bool { mk = append(mk, rcpt) } } - if len(mk) > 0 { + switch { + case len(mk) > 0: c.SetEncrypt(false) st := fmt.Sprintf("Cannot encrypt, missing keys: %s", strings.Join(mk, ", ")) + if c.Config().PgpOpportunisticEncrypt { + switch c.Config().PgpErrorLevel { + case config.PgpErrorLevelWarn: + c.aerc.statusline.PushWarning(st) + return false + case config.PgpErrorLevelNone: + return false + case config.PgpErrorLevelError: + // Continue to the default + } + } c.aerc.statusline.PushError(st) return false + case len(rcpts) == 0: + return false } // If callbacks were registered, encrypt will be set when user removes // recipients with missing keys |