Skip to content

Commit

Permalink
fix handle resolution in some cli commands (#631)
Browse files Browse the repository at this point in the history
probably more of this to come, the ProdHandleResolver type is basically
broken now
  • Loading branch information
bnewbold committed Jun 27, 2024
2 parents dcbf733 + 2f49d1e commit b582675
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
18 changes: 11 additions & 7 deletions cmd/gosky/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ var adminCmd = &cli.Command{
EnvVars: []string{"ATP_AUTH_ADMIN_PASSWORD"},
Required: true,
},
&cli.StringFlag{
Name: "admin-endpoint",
Value: "https://mod.bsky.app",
},
},
Subcommands: []*cli.Command{
buildInviteTreeCmd,
Expand Down Expand Up @@ -78,7 +82,7 @@ var checkUserCmd = &cli.Command{

adminKey := cctx.String("admin-password")
xrpcc.AdminToken = &adminKey
xrpcc.Host = id.PDSEndpoint()
xrpcc.Host = cctx.String("admin-endpoint")

rep, err := toolsozone.ModerationGetRepo(ctx, xrpcc, did)
if err != nil {
Expand Down Expand Up @@ -623,25 +627,25 @@ var takeDownAccountCmd = &cli.Command{

for _, did := range cctx.Args().Slice() {
if !strings.HasPrefix(did, "did:") {
phr := &api.ProdHandleResolver{}
resp, err := phr.ResolveHandleToDid(ctx, did)
dir := identity.DefaultDirectory()
resp, err := dir.LookupHandle(ctx, syntax.Handle(did))
if err != nil {
return err
}

did = resp
did = resp.DID.String()
}

reason := cctx.String("reason")
adminUser := cctx.String("admin-user")
if !strings.HasPrefix(adminUser, "did:") {
phr := &api.ProdHandleResolver{}
resp, err := phr.ResolveHandleToDid(ctx, adminUser)
dir := identity.DefaultDirectory()
resp, err := dir.LookupHandle(ctx, syntax.Handle(adminUser))
if err != nil {
return err
}

adminUser = resp
adminUser = resp.DID.String()
}

resp, err := toolsozone.ModerationEmitEvent(ctx, xrpcc, &toolsozone.ModerationEmitEvent_Input{
Expand Down
16 changes: 11 additions & 5 deletions cmd/gosky/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"context"
"fmt"

api "github.com/bluesky-social/indigo/api"
comatproto "github.com/bluesky-social/indigo/api/atproto"
"github.com/bluesky-social/indigo/atproto/identity"
"github.com/bluesky-social/indigo/atproto/syntax"
"github.com/bluesky-social/indigo/util/cliutil"

cli "github.com/urfave/cli/v2"
Expand All @@ -30,15 +31,20 @@ var resolveHandleCmd = &cli.Command{
if err != nil {
return err
}
handle := args[0]

phr := &api.ProdHandleResolver{}
out, err := phr.ResolveHandleToDid(ctx, handle)
h, err := syntax.ParseHandle(args[0])
if err != nil {
return fmt.Errorf("resolving %q: %w", args[0], err)
}

dir := identity.DefaultDirectory()

res, err := dir.LookupHandle(ctx, h)
if err != nil {
return err
}

fmt.Println(out)
fmt.Println(res.DID)

return nil
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/gosky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ var listLabelsCmd = &cli.Command{
since := time.Now().Add(-1 * delta).UnixMilli()

xrpcc := &xrpc.Client{
Host: "https://api.bsky.app",
Host: "https://mod.bsky.app",
}

for {
Expand Down

0 comments on commit b582675

Please sign in to comment.