pgp: add attach key command

Add compose command ("attach-key") to attach the public key associated
with the sending account. Public key is attached in ascii armor format,
with the mimetype set according to RFC 3156 ("application/pgp-keys").

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:16 -05:00 committed by Robin Jarry
parent 32a16dcd8d
commit b57fceaad4
7 changed files with 174 additions and 3 deletions
commands/compose

View file

@ -0,0 +1,32 @@
package compose
import (
"errors"
"git.sr.ht/~rjarry/aerc/widgets"
)
type AttachKey struct{}
func init() {
register(AttachKey{})
}
func (AttachKey) Aliases() []string {
return []string{"attach-key"}
}
func (AttachKey) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
}
func (AttachKey) Execute(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
return errors.New("Usage: attach-key")
}
composer, _ := aerc.SelectedTab().(*widgets.Composer)
composer.SetAttachKey(!composer.AttachKey())
return nil
}