github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/service/identify3.go (about)

     1  package service
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/keybase/client/go/identify3"
     6  	"github.com/keybase/client/go/libkb"
     7  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
     8  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
     9  	"golang.org/x/net/context"
    10  )
    11  
    12  // identify3Handler handles one RPC in the identify3 flow
    13  type identify3Handler struct {
    14  	libkb.Contextified
    15  	xp rpc.Transporter
    16  }
    17  
    18  func (i *identify3Handler) newMetaContext(ctx context.Context) libkb.MetaContext {
    19  	return libkb.NewMetaContext(ctx, i.G()).WithLogTag("ID3")
    20  }
    21  
    22  func newIdentify3Handler(xp rpc.Transporter, g *libkb.GlobalContext) *identify3Handler {
    23  	return &identify3Handler{
    24  		Contextified: libkb.NewContextified(g),
    25  		xp:           xp,
    26  	}
    27  }
    28  
    29  func (i *identify3Handler) Identify3(ctx context.Context, arg keybase1.Identify3Arg) (err error) {
    30  	mctx := i.newMetaContext(ctx)
    31  	defer mctx.Trace(fmt.Sprintf("Identify3(%+v)", arg), &err)()
    32  	cli := rpc.NewClient(i.xp, libkb.NewContextifiedErrorUnwrapper(mctx.G()), nil)
    33  	id3cli := keybase1.Identify3UiClient{Cli: cli}
    34  	return identify3.Identify3(mctx, id3cli, arg)
    35  }
    36  
    37  func (i *identify3Handler) Identify3FollowUser(ctx context.Context, arg keybase1.Identify3FollowUserArg) (err error) {
    38  	mctx := i.newMetaContext(ctx)
    39  	defer mctx.Trace(fmt.Sprintf("Identify3FollowUser(%+v)", arg), &err)()
    40  	return identify3.FollowUser(mctx, arg)
    41  }
    42  
    43  func (i *identify3Handler) Identify3IgnoreUser(ctx context.Context, guiID keybase1.Identify3GUIID) (err error) {
    44  	mctx := i.newMetaContext(ctx)
    45  	defer mctx.Trace(fmt.Sprintf("Identify3IgnoreUser(%+v)", guiID), &err)()
    46  	return identify3.IgnoreUser(mctx, guiID)
    47  }
    48  
    49  var _ keybase1.Identify3Interface = (*identify3Handler)(nil)