this repo has no description
0
fork

Configure Feed

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

Allow bulk dids for takedown (#330)

- Modifies`takeDownAccountCmd` to take multiple dids for bulk takedowns
- Renames cli command `takeDownAccount` to standardize with other
commands

Example command:
`./gosky admin take-down --reason="<reason here>" --admin-user="<did
here>" --revert-actions exampleuser.bsky.social
exampleuser2.bsky.social`

authored by

Whyrusleeping and committed by
GitHub
3eba8179 e6006483

+54 -53
+54 -53
cmd/gosky/admin.go
··· 626 626 } 627 627 628 628 var takeDownAccountCmd = &cli.Command{ 629 - Name: "take-down", 629 + Name: "takeDownAccount", 630 630 Flags: []cli.Flag{ 631 631 &cli.StringFlag{ 632 632 Name: "admin-password", ··· 660 660 adminKey := cctx.String("admin-password") 661 661 xrpcc.AdminToken = &adminKey 662 662 663 - did := cctx.Args().First() 664 - if !strings.HasPrefix(did, "did:") { 665 - phr := &api.ProdHandleResolver{} 666 - resp, err := phr.ResolveHandleToDid(ctx, did) 667 - if err != nil { 668 - return err 663 + for _, did := range cctx.Args().Slice() { 664 + if !strings.HasPrefix(did, "did:") { 665 + phr := &api.ProdHandleResolver{} 666 + resp, err := phr.ResolveHandleToDid(ctx, did) 667 + if err != nil { 668 + return err 669 + } 670 + 671 + did = resp 669 672 } 670 673 671 - did = resp 672 - } 674 + reason := cctx.String("reason") 675 + adminUser := cctx.String("admin-user") 676 + if !strings.HasPrefix(adminUser, "did:") { 677 + phr := &api.ProdHandleResolver{} 678 + resp, err := phr.ResolveHandleToDid(ctx, adminUser) 679 + if err != nil { 680 + return err 681 + } 673 682 674 - reason := cctx.String("reason") 675 - adminUser := cctx.String("admin-user") 676 - if !strings.HasPrefix(adminUser, "did:") { 677 - phr := &api.ProdHandleResolver{} 678 - resp, err := phr.ResolveHandleToDid(ctx, adminUser) 679 - if err != nil { 680 - return err 683 + adminUser = resp 681 684 } 682 685 683 - adminUser = resp 684 - } 686 + if cctx.Bool("revert-actions") { 687 + resp, err := atproto.AdminGetModerationActions(ctx, xrpcc, "", 100, did) 688 + if err != nil { 689 + return err 690 + } 685 691 686 - if cctx.Bool("revert-actions") { 687 - resp, err := atproto.AdminGetModerationActions(ctx, xrpcc, "", 100, did) 688 - if err != nil { 689 - return err 690 - } 692 + for _, act := range resp.Actions { 693 + if act.Action == nil || *act.Action != "com.atproto.admin.defs#acknowledge" { 694 + return fmt.Errorf("will only revert acknowledge actions") 695 + } 691 696 692 - for _, act := range resp.Actions { 693 - if act.Action == nil || *act.Action != "com.atproto.admin.defs#acknowledge" { 694 - return fmt.Errorf("will only revert acknowledge actions") 697 + _, err := atproto.AdminReverseModerationAction(ctx, xrpcc, &atproto.AdminReverseModerationAction_Input{ 698 + CreatedBy: adminUser, 699 + Id: act.Id, 700 + Reason: "reverting for takedown", 701 + }) 702 + if err != nil { 703 + return fmt.Errorf("failed to revert existing action: %w", err) 704 + } 695 705 } 696 706 697 - _, err := atproto.AdminReverseModerationAction(ctx, xrpcc, &atproto.AdminReverseModerationAction_Input{ 698 - CreatedBy: adminUser, 699 - Id: act.Id, 700 - Reason: "reverting for takedown", 701 - }) 702 - if err != nil { 703 - return fmt.Errorf("failed to revert existing action: %w", err) 704 - } 705 707 } 706 708 707 - } 709 + resp, err := atproto.AdminTakeModerationAction(ctx, xrpcc, &atproto.AdminTakeModerationAction_Input{ 710 + Action: "com.atproto.admin.defs#takedown", 711 + Reason: reason, 712 + CreatedBy: adminUser, 713 + Subject: &atproto.AdminTakeModerationAction_Input_Subject{ 714 + AdminDefs_RepoRef: &atproto.AdminDefs_RepoRef{ 715 + Did: did, 716 + }, 717 + }, 718 + }) 719 + if err != nil { 720 + return err 721 + } 708 722 709 - resp, err := atproto.AdminTakeModerationAction(ctx, xrpcc, &atproto.AdminTakeModerationAction_Input{ 710 - Action: "com.atproto.admin.defs#takedown", 711 - Reason: reason, 712 - CreatedBy: adminUser, 713 - Subject: &atproto.AdminTakeModerationAction_Input_Subject{ 714 - AdminDefs_RepoRef: &atproto.AdminDefs_RepoRef{ 715 - Did: did, 716 - }, 717 - }, 718 - }) 719 - if err != nil { 720 - return err 721 - } 723 + b, err := json.MarshalIndent(resp, "", " ") 724 + if err != nil { 725 + return err 726 + } 722 727 723 - b, err := json.MarshalIndent(resp, "", " ") 724 - if err != nil { 725 - return err 728 + fmt.Println(string(b)) 726 729 } 727 - 728 - fmt.Println(string(b)) 729 730 return nil 730 731 }, 731 732 }