github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/service/sigs.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 package service 5 6 import ( 7 "github.com/keybase/client/go/engine" 8 "github.com/keybase/client/go/libkb" 9 keybase1 "github.com/keybase/client/go/protocol/keybase1" 10 "github.com/keybase/go-framed-msgpack-rpc/rpc" 11 "golang.org/x/net/context" 12 ) 13 14 // SigsHandler is the RPC handler for the sigs interface. 15 type SigsHandler struct { 16 *BaseHandler 17 libkb.Contextified 18 } 19 20 // NewSigsHandler creates a SigsHandler for the xp transport. 21 func NewSigsHandler(xp rpc.Transporter, g *libkb.GlobalContext) *SigsHandler { 22 return &SigsHandler{ 23 BaseHandler: NewBaseHandler(g, xp), 24 Contextified: libkb.NewContextified(g), 25 } 26 } 27 28 func (h *SigsHandler) SigList(ctx context.Context, arg keybase1.SigListArg) ([]keybase1.Sig, error) { 29 eng, err := h.run(ctx, arg.Arg) 30 if err != nil { 31 return nil, err 32 } 33 return eng.Sigs(), nil 34 } 35 36 func (h *SigsHandler) SigListJSON(ctx context.Context, arg keybase1.SigListJSONArg) (string, error) { 37 eng, err := h.run(ctx, arg.Arg) 38 if err != nil { 39 return "", err 40 } 41 return eng.JSON() 42 } 43 44 func (h *SigsHandler) run(ctx context.Context, args keybase1.SigListArgs) (*engine.SigsList, error) { 45 46 ea := engine.SigsListArgs{ 47 Username: args.Username, 48 Filterx: args.Filterx, 49 Verbose: args.Verbose, 50 Revoked: args.Revoked, 51 Types: nil, 52 } 53 if args.Types != nil { 54 t := make(map[string]bool) 55 f := func(v bool, name string) { 56 if v { 57 t[name] = true 58 } 59 } 60 f(args.Types.Track, "track") 61 f(args.Types.Proof, "proof") 62 f(args.Types.Cryptocurrency, "cryptocurrency") 63 f(args.Types.IsSelf, "self") 64 ea.Types = t 65 } 66 eng := engine.NewSigsList(h.G(), ea) 67 m := libkb.NewMetaContext(ctx, h.G()) 68 if err := engine.RunEngine2(m, eng); err != nil { 69 return nil, err 70 } 71 return eng, nil 72 }