this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

quick command to list all dids invited recursively by a user (#236)

authored by

Whyrusleeping and committed by
GitHub
17a856f2 d7bf04ac

+74
+74
cmd/gosky/admin.go
··· 24 24 reportsCmd, 25 25 disableInvitesCmd, 26 26 enableInvitesCmd, 27 + listInviteTreeCmd, 27 28 }, 28 29 } 29 30 ··· 498 499 }) 499 500 }, 500 501 } 502 + 503 + var listInviteTreeCmd = &cli.Command{ 504 + Name: "listInviteTree", 505 + Flags: []cli.Flag{ 506 + &cli.StringFlag{ 507 + Name: "admin-password", 508 + EnvVars: []string{"ATP_AUTH_ADMIN_PASSWORD"}, 509 + Required: true, 510 + }, 511 + &cli.StringFlag{ 512 + Name: "plc", 513 + Usage: "method, hostname, and port of PLC registry", 514 + Value: "https://plc.directory", 515 + EnvVars: []string{"ATP_PLC_HOST"}, 516 + }, 517 + &cli.BoolFlag{ 518 + Name: "disable-invites", 519 + Usage: "additionally disable invites for all printed DIDs", 520 + }, 521 + }, 522 + ArgsUsage: `[handle]`, 523 + Action: func(cctx *cli.Context) error { 524 + xrpcc, err := cliutil.GetXrpcClient(cctx, false) 525 + if err != nil { 526 + return err 527 + } 528 + 529 + ctx := context.Background() 530 + 531 + phr := &api.ProdHandleResolver{} 532 + 533 + did := cctx.Args().First() 534 + if !strings.HasPrefix(did, "did:") { 535 + rdid, err := phr.ResolveHandleToDid(ctx, cctx.Args().First()) 536 + if err != nil { 537 + return fmt.Errorf("resolve handle %q: %w", cctx.Args().First(), err) 538 + } 539 + 540 + did = rdid 541 + } 542 + 543 + adminKey := cctx.String("admin-password") 544 + xrpcc.AdminToken = &adminKey 545 + 546 + queue := []string{did} 547 + 548 + for len(queue) > 0 { 549 + next := queue[0] 550 + queue = queue[1:] 551 + 552 + if cctx.Bool("disable-invites") { 553 + if err := atproto.AdminDisableAccountInvites(ctx, xrpcc, &atproto.AdminDisableAccountInvites_Input{ 554 + Account: next, 555 + }); err != nil { 556 + return fmt.Errorf("failed to disable invites on %q: %w", next, err) 557 + } 558 + } 559 + 560 + rep, err := atproto.AdminGetRepo(ctx, xrpcc, next) 561 + if err != nil { 562 + return fmt.Errorf("getRepo %s: %w", did, err) 563 + } 564 + 565 + for _, inv := range rep.Invites { 566 + for _, u := range inv.Uses { 567 + fmt.Println(u.UsedBy) 568 + queue = append(queue, u.UsedBy) 569 + } 570 + } 571 + } 572 + return nil 573 + }, 574 + }