pgp: add options auto-sign & opportunistic-encrypt

Add account level config options for auto-sign and opportunistic
encryption.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
Tim Culverhouse 2022-05-05 12:53:14 -05:00 committed by Robin Jarry
parent 5c5158b3c1
commit bb400c7d88
3 changed files with 29 additions and 1 deletions

View File

@ -104,7 +104,11 @@ type AccountConfig struct {
SignatureCmd string SignatureCmd string
EnableFoldersSort bool `ini:"enable-folders-sort"` EnableFoldersSort bool `ini:"enable-folders-sort"`
FoldersSort []string `ini:"folders-sort" delim:","` FoldersSort []string `ini:"folders-sort" delim:","`
PgpKeyId string `ini:"pgp-key-id"`
// PGP Config
PgpKeyId string `ini:"pgp-key-id"`
PgpAutoSign bool `ini:"pgp-auto-sign"`
PgpOpportunisticEncrypt bool `ini:"pgp-opportunistic-encrypt"`
} }
type BindingConfig struct { type BindingConfig struct {
@ -251,6 +255,10 @@ func loadAccountConfig(path string) ([]AccountConfig, error) {
account.EnableFoldersSort, _ = strconv.ParseBool(val) account.EnableFoldersSort, _ = strconv.ParseBool(val)
} else if key == "pgp-key-id" { } else if key == "pgp-key-id" {
account.PgpKeyId = val account.PgpKeyId = val
} else if key == "pgp-auto-sign" {
account.PgpAutoSign, _ = strconv.ParseBool(val)
} else if key == "pgp-opportunistic-encrypt" {
account.PgpOpportunisticEncrypt, _ = strconv.ParseBool(val)
} else if key != "name" { } else if key != "name" {
account.Params[key] = val account.Params[key] = val
} }

View File

@ -588,10 +588,23 @@ Note that many of these configuration options are written for you, such as
Default: none Default: none
*pgp-auto-sign*
If true, all outgoing emails from this account will be signed (if a signing
key is available)
Default: false
*pgp-key-id* *pgp-key-id*
Specify the key id to use when signing a message. Can be either short or Specify the key id to use when signing a message. Can be either short or
long key id. If unset, aerc will look up the key by email long key id. If unset, aerc will look up the key by email
*pgp-opportunistic-encrypt*
If true, any outgoing email from this account will be encrypted when all
recipients (including "cc" and "bcc" field) have a public key available in
the keyring
Default: false
*postpone* *postpone*
Specifies the folder to save postponed messages to. Specifies the folder to save postponed messages to.

View File

@ -118,6 +118,13 @@ func NewComposer(aerc *Aerc, acct *AccountView, conf *config.AercConfig,
c.updateCrypto() c.updateCrypto()
c.ShowTerminal() c.ShowTerminal()
if c.acctConfig.PgpAutoSign {
c.SetSign(true)
}
if c.acctConfig.PgpOpportunisticEncrypt {
c.SetEncrypt(true)
}
return c, nil return c, nil
} }