Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle resolution does not depend on any xrpc routes #433

Merged
merged 1 commit into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading