From 05df6253db975d09f421c49bf0a1c75f8ba822fb Mon Sep 17 00:00:00 2001 From: Jon Lundy Date: Wed, 2 Dec 2020 09:24:07 -0700 Subject: [PATCH] fixes to gpg key and twt proofs --- Makefile | 2 +- pkg/keyproofs/opengpg.go | 11 ++++------- pkg/keyproofs/proofs.go | 9 +++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 94d3aeb..58460a4 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ version: @echo $(VERSION) tag: git tag -a v$(VERSION) -m "Version: $(VERSION)" - git push --tag + git push --follow-tags release: @make tag BUMP=patch run: diff --git a/pkg/keyproofs/opengpg.go b/pkg/keyproofs/opengpg.go index 5c0cb40..6ac86ca 100644 --- a/pkg/keyproofs/opengpg.go +++ b/pkg/keyproofs/opengpg.go @@ -146,24 +146,21 @@ func ReadKey(r io.Reader, useArmored bool) (e *Entity, err error) { var buf bytes.Buffer var w io.Writer = &buf - e = &Entity{} + defer func(){ if e != nil { e.ArmorText = buf.String() }}() + + if !useArmored { var aw io.WriteCloser aw, err = armor.Encode(&buf, "PGP PUBLIC KEY BLOCK", nil) if err != nil { return e, fmt.Errorf("Read key: %w", err) } - defer aw.Close() + defer aw.Close() w = aw } - defer func() { - if e != nil { - e.ArmorText = buf.String() - } - }() r = io.TeeReader(r, w) diff --git a/pkg/keyproofs/proofs.go b/pkg/keyproofs/proofs.go index 138a77c..446fe77 100644 --- a/pkg/keyproofs/proofs.go +++ b/pkg/keyproofs/proofs.go @@ -210,7 +210,7 @@ func NewProof(ctx context.Context, uri, fingerprint string) ProofResolver { if sp := strings.SplitN(p.URI.Path, "/", 3); len(sp) == 3 { p.Icon = "fas fa-comment-alt" p.Service = "Twtxt" - p.Name = "loading..." + p.Name = fmt.Sprintf("...@%s", p.URI.Host) p.Link = fmt.Sprintf("https://%s", p.URI.Host) url := fmt.Sprintf("https://%s/api/v1/conv", p.URI.Host) @@ -338,10 +338,11 @@ func (t *twtxtResolve) Resolve(ctx context.Context) error { return err } if len(twt.Twts) > 0 { - t.proof.Name = twt.Twts[0].Twter.Nick - t.proof.Link += "/user/" + twt.Twts[0].Twter.Nick + nick := twt.Twts[0].Twter.Nick + t.proof.Name = fmt.Sprintf("%s@%s", nick, t.proof.URI.Host) + t.proof.Link += "/user/" + nick - ck := fmt.Sprintf("[Verifying my OpenPGP key: openpgp4fpr:%s]", strings.ToLower(t.proof.Fingerprint)) + ck := fmt.Sprintf("[Verifying my OpenPGP key: openpgp4fpr:%s]", t.proof.Fingerprint) if strings.Contains(twt.Twts[0].Text, ck) { t.proof.Status = ProofVerified return nil