aerc/commands/compose/sign.go
Tim Culverhouse dbf52bb4b4 pgp: check for signing key before signing time
Check that the signing key exists when the user issues the :sign
command. The signing key ID will be displayed in the security status
also, allowing the user to see what key will be used to sign the
message.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Jens Grassel <jens@wegtam.com>
2022-05-04 14:07:15 +02:00

48 lines
742 B
Go

package compose
import (
"errors"
"time"
"git.sr.ht/~rjarry/aerc/widgets"
)
type Sign struct{}
func init() {
register(Sign{})
}
func (Sign) Aliases() []string {
return []string{"sign"}
}
func (Sign) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
}
func (Sign) Execute(aerc *widgets.Aerc, args []string) error {
if len(args) != 1 {
return errors.New("Usage: sign")
}
composer, _ := aerc.SelectedTab().(*widgets.Composer)
err := composer.SetSign(!composer.Sign())
if err != nil {
return err
}
var statusline string
if composer.Sign() {
statusline = "Message will be signed."
} else {
statusline = "Message will not be signed."
}
aerc.PushStatus(statusline, 10*time.Second)
return nil
}