porting all github actions from bluesky-social/indigo to tangled CI

fixup recently broken did resolution commands

Changed files
+31 -25
cmd
+24 -21
cmd/gosky/admin.go
··· 13 13 "github.com/bluesky-social/indigo/api" 14 14 "github.com/bluesky-social/indigo/api/atproto" 15 15 comatproto "github.com/bluesky-social/indigo/api/atproto" 16 + "github.com/bluesky-social/indigo/atproto/identity" 17 + "github.com/bluesky-social/indigo/atproto/syntax" 16 18 "github.com/bluesky-social/indigo/util/cliutil" 17 19 cli "github.com/urfave/cli/v2" 18 20 ) ··· 58 60 return err 59 61 } 60 62 63 + dir := identity.DefaultDirectory() 61 64 ctx := context.Background() 62 65 63 - phr := &api.ProdHandleResolver{} 66 + ident, err := syntax.ParseAtIdentifier(cctx.Args().First()) 67 + if err != nil { 68 + return err 69 + } 64 70 65 - did := cctx.Args().First() 66 - if !strings.HasPrefix(did, "did:") { 67 - rdid, err := phr.ResolveHandleToDid(ctx, cctx.Args().First()) 68 - if err != nil { 69 - return fmt.Errorf("resolve handle %q: %w", cctx.Args().First(), err) 70 - } 71 + id, err := dir.Lookup(ctx, *ident) 72 + if err != nil { 73 + return fmt.Errorf("resolve identifier %q: %w", cctx.Args().First(), err) 74 + } 71 75 72 - did = rdid 73 - } 76 + did := id.DID.String() 74 77 75 78 adminKey := cctx.String("admin-password") 76 79 xrpcc.AdminToken = &adminKey 80 + xrpcc.Host = id.PDSEndpoint() 77 81 78 82 rep, err := atproto.AdminGetRepo(ctx, xrpcc, did) 79 83 if err != nil { ··· 85 89 return err 86 90 } 87 91 88 - plcc := cliutil.GetDidResolver(cctx) 89 - 90 92 if cctx.Bool("raw") { 91 93 fmt.Println(string(b)) 92 94 } else if cctx.Bool("list-invited-dids") { ··· 97 99 } 98 100 } else { 99 101 var invby string 100 - if fa := rep.InvitedBy.ForAccount; fa != "" { 101 - if fa == "admin" { 102 - invby = fa 103 - } else { 104 - handle, _, err := api.ResolveDidToHandle(ctx, plcc, phr, fa) 105 - if err != nil { 106 - fmt.Println("ERROR: failed to resolve inviter: ", err) 107 - handle = fa 108 - } 102 + if rep.InvitedBy != nil { 103 + if fa := rep.InvitedBy.ForAccount; fa != "" { 104 + if fa == "admin" { 105 + invby = fa 106 + } else { 107 + id, err := dir.LookupDID(ctx, syntax.DID(fa)) 108 + if err != nil { 109 + fmt.Println("ERROR: failed to resolve inviter: ", err) 110 + } 109 111 110 - invby = handle 112 + invby = id.Handle.String() 113 + } 111 114 } 112 115 } 113 116
+7 -4
cmd/gosky/did.go
··· 5 5 "encoding/json" 6 6 "fmt" 7 7 8 - "github.com/bluesky-social/indigo/api" 8 + "github.com/bluesky-social/indigo/atproto/identity" 9 + "github.com/bluesky-social/indigo/atproto/syntax" 9 10 "github.com/bluesky-social/indigo/util/cliutil" 10 11 11 12 cli "github.com/urfave/cli/v2" ··· 34 35 Action: func(cctx *cli.Context) error { 35 36 s := cliutil.GetDidResolver(cctx) 36 37 38 + ctx := context.TODO() 37 39 did := cctx.Args().First() 38 40 41 + dir := identity.DefaultDirectory() 42 + 39 43 if cctx.Bool("handle") { 40 - phr := &api.ProdHandleResolver{} 41 - h, _, err := api.ResolveDidToHandle(context.TODO(), s, phr, did) 44 + id, err := dir.LookupDID(ctx, syntax.DID(did)) 42 45 if err != nil { 43 46 return err 44 47 } 45 48 46 - fmt.Println(h) 49 + fmt.Println(id.Handle) 47 50 return nil 48 51 } 49 52