diff options
Diffstat (limited to 'widgets/pgpinfo.go')
-rw-r--r-- | widgets/pgpinfo.go | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/widgets/pgpinfo.go b/widgets/pgpinfo.go index 6c07ed91..8dc05707 100644 --- a/widgets/pgpinfo.go +++ b/widgets/pgpinfo.go @@ -1,22 +1,18 @@ package widgets import ( - "errors" - "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib/ui" - - "github.com/ProtonMail/go-crypto/openpgp" - pgperrors "github.com/ProtonMail/go-crypto/openpgp/errors" + "git.sr.ht/~rjarry/aerc/models" ) type PGPInfo struct { ui.Invalidatable - details *openpgp.MessageDetails + details *models.MessageDetails uiConfig config.UIConfig } -func NewPGPInfo(details *openpgp.MessageDetails, uiConfig config.UIConfig) *PGPInfo { +func NewPGPInfo(details *models.MessageDetails, uiConfig config.UIConfig) *PGPInfo { return &PGPInfo{details: details, uiConfig: uiConfig} } @@ -27,38 +23,33 @@ func (p *PGPInfo) DrawSignature(ctx *ui.Context) { defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT) // TODO: Nicer prompt for TOFU, fetch from keyserver, etc - if errors.Is(p.details.SignatureError, pgperrors.ErrUnknownIssuer) || - p.details.SignedBy == nil { + if p.details.SignatureValidity == models.UnknownEntity || + p.details.SignedBy == "" { x := ctx.Printf(0, 0, warningStyle, "*") x += ctx.Printf(x, 0, defaultStyle, " Signed with unknown key (%8X); authenticity unknown", p.details.SignedByKeyId) - } else if p.details.SignatureError != nil { + } else if p.details.SignatureValidity != models.Valid { x := ctx.Printf(0, 0, errorStyle, "Invalid signature!") x += ctx.Printf(x, 0, errorStyle, " This message may have been tampered with! (%s)", - p.details.SignatureError.Error()) + p.details.SignatureError) } else { - entity := p.details.SignedBy.Entity - ident := entity.PrimaryIdentity() - x := ctx.Printf(0, 0, validStyle, "✓ Authentic ") x += ctx.Printf(x, 0, defaultStyle, "Signature from %s (%8X)", - ident.Name, p.details.SignedByKeyId) + p.details.SignedBy, p.details.SignedByKeyId) } } func (p *PGPInfo) DrawEncryption(ctx *ui.Context, y int) { validStyle := p.uiConfig.GetStyle(config.STYLE_SUCCESS) defaultStyle := p.uiConfig.GetStyle(config.STYLE_DEFAULT) - entity := p.details.DecryptedWith.Entity - ident := entity.PrimaryIdentity() x := ctx.Printf(0, y, validStyle, "✓ Encrypted ") x += ctx.Printf(x, y, defaultStyle, - "To %s (%8X) ", ident.Name, p.details.DecryptedWith.PublicKey.KeyId) + "To %s (%8X) ", p.details.DecryptedWith, p.details.DecryptedWithKeyId) } func (p *PGPInfo) Draw(ctx *ui.Context) { |