Skip to content

Commit

Permalink
handle resolution does not depend on any xrpc routes
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Nov 11, 2023
1 parent 1e3e99d commit 4e474e9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
7 changes: 1 addition & 6 deletions api/extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/bluesky-social/indigo/did"
"github.com/bluesky-social/indigo/xrpc"
arc "github.com/hashicorp/golang-lru/arc/v2"
logging "github.com/ipfs/go-log"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
Expand All @@ -22,7 +21,7 @@ import (

var log = logging.Logger("api")

func ResolveDidToHandle(ctx context.Context, xrpcc *xrpc.Client, res did.Resolver, hr HandleResolver, udid string) (string, string, error) {
func ResolveDidToHandle(ctx context.Context, res did.Resolver, hr HandleResolver, udid string) (string, string, error) {
ctx, span := otel.Tracer("gosky").Start(ctx, "resolveDidToHandle")
defer span.End()

Expand Down Expand Up @@ -56,10 +55,6 @@ func ResolveDidToHandle(ctx context.Context, xrpcc *xrpc.Client, res did.Resolve
return "", "", fmt.Errorf("users did document has no pds service set")
}

if xrpcc.Host != "*" && svc.ServiceEndpoint != xrpcc.Host {
return "", "", fmt.Errorf("our XRPC client is authed for a different pds (%s != %s)", svc.ServiceEndpoint, xrpcc.Host)
}

verdid, err := hr.ResolveHandleToDid(ctx, handle)
if err != nil {
return "", "", err
Expand Down
2 changes: 1 addition & 1 deletion cmd/gosky/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var checkUserCmd = &cli.Command{
if fa == "admin" {
invby = fa
} else {
handle, _, err := api.ResolveDidToHandle(ctx, xrpcc, plcc, phr, fa)
handle, _, err := api.ResolveDidToHandle(ctx, plcc, phr, fa)
if err != nil {
fmt.Println("ERROR: failed to resolve inviter: ", err)
handle = fa
Expand Down
7 changes: 1 addition & 6 deletions cmd/gosky/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ var didGetCmd = &cli.Command{
did := cctx.Args().First()

if cctx.Bool("handle") {
xrpcc, err := cliutil.GetXrpcClient(cctx, false)
if err != nil {
return err
}

phr := &api.ProdHandleResolver{}
h, _, err := api.ResolveDidToHandle(context.TODO(), xrpcc, s, phr, did)
h, _, err := api.ResolveDidToHandle(context.TODO(), s, phr, did)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/gosky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/bluesky-social/indigo/repo"
"github.com/bluesky-social/indigo/util"
"github.com/bluesky-social/indigo/util/cliutil"
"github.com/bluesky-social/indigo/xrpc"
"golang.org/x/time/rate"

"github.com/gorilla/websocket"
Expand Down Expand Up @@ -196,7 +195,7 @@ var readRepoStreamCmd = &cli.Command{
}
}

h, _, err := api.ResolveDidToHandle(ctx, &xrpc.Client{Host: "*"}, didr, hr, did)
h, _, err := api.ResolveDidToHandle(ctx, didr, hr, did)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 4e474e9

Please sign in to comment.