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 /config/accounts.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 'config/accounts.go')
-rw-r--r-- | config/accounts.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/config/accounts.go b/config/accounts.go index 6cd30098..cbdf54a8 100644 --- a/config/accounts.go +++ b/config/accounts.go @@ -101,11 +101,18 @@ type AccountConfig struct { PgpKeyId string `ini:"pgp-key-id"` PgpAutoSign bool `ini:"pgp-auto-sign"` PgpOpportunisticEncrypt bool `ini:"pgp-opportunistic-encrypt"` + PgpErrorLevel int `ini:"pgp-error-level"` // AuthRes TrustedAuthRes []string `ini:"trusted-authres" delim:","` } +const ( + PgpErrorLevelNone = iota + PgpErrorLevelWarn + PgpErrorLevelError +) + var Accounts []*AccountConfig func parseAccounts(root string, accts []string) error { @@ -142,6 +149,7 @@ func parseAccounts(root string, accts []string) error { Params: make(map[string]string), EnableFoldersSort: true, CheckMailTimeout: 10 * time.Second, + PgpErrorLevel: PgpErrorLevelWarn, // localizedRe contains a list of known translations for the common Re: LocalizedRe: regexp.MustCompile(`(?i)^((AW|RE|SV|VS|ODP|R): ?)+`), } @@ -182,6 +190,17 @@ func parseAccounts(root string, accts []string) error { return fmt.Errorf("%s=%s %w", key, val, err) } account.LocalizedRe = re + case "pgp-error-level": + switch strings.ToLower(val) { + case "none": + account.PgpErrorLevel = PgpErrorLevelNone + case "warn": + account.PgpErrorLevel = PgpErrorLevelWarn + case "error": + account.PgpErrorLevel = PgpErrorLevelError + default: + return fmt.Errorf("unknown pgp-error-level: %s", val) + } default: backendSpecific := true typ := reflect.TypeOf(account) @@ -201,6 +220,8 @@ func parseAccounts(root string, accts []string) error { case "outgoing-cred-cmd-cache": fallthrough case "subject-re-pattern": + fallthrough + case "pgp-error-level": backendSpecific = false } } |