diff --git a/cmd/gosky/admin.go b/cmd/gosky/admin.go index 911969c39..8134897dc 100644 --- a/cmd/gosky/admin.go +++ b/cmd/gosky/admin.go @@ -626,7 +626,7 @@ var listInviteTreeCmd = &cli.Command{ } var takeDownAccountCmd = &cli.Command{ - Name: "take-down", + Name: "takeDownAccount", Flags: []cli.Flag{ &cli.StringFlag{ Name: "admin-password", @@ -660,72 +660,73 @@ var takeDownAccountCmd = &cli.Command{ adminKey := cctx.String("admin-password") xrpcc.AdminToken = &adminKey - did := cctx.Args().First() - if !strings.HasPrefix(did, "did:") { - phr := &api.ProdHandleResolver{} - resp, err := phr.ResolveHandleToDid(ctx, did) - if err != nil { - return err - } - - did = resp - } + for _, did := range cctx.Args().Slice() { + if !strings.HasPrefix(did, "did:") { + phr := &api.ProdHandleResolver{} + resp, err := phr.ResolveHandleToDid(ctx, did) + if err != nil { + return err + } - reason := cctx.String("reason") - adminUser := cctx.String("admin-user") - if !strings.HasPrefix(adminUser, "did:") { - phr := &api.ProdHandleResolver{} - resp, err := phr.ResolveHandleToDid(ctx, adminUser) - if err != nil { - return err + did = resp } - adminUser = resp - } + reason := cctx.String("reason") + adminUser := cctx.String("admin-user") + if !strings.HasPrefix(adminUser, "did:") { + phr := &api.ProdHandleResolver{} + resp, err := phr.ResolveHandleToDid(ctx, adminUser) + if err != nil { + return err + } - if cctx.Bool("revert-actions") { - resp, err := atproto.AdminGetModerationActions(ctx, xrpcc, "", 100, did) - if err != nil { - return err + adminUser = resp } - for _, act := range resp.Actions { - if act.Action == nil || *act.Action != "com.atproto.admin.defs#acknowledge" { - return fmt.Errorf("will only revert acknowledge actions") + if cctx.Bool("revert-actions") { + resp, err := atproto.AdminGetModerationActions(ctx, xrpcc, "", 100, did) + if err != nil { + return err } - _, err := atproto.AdminReverseModerationAction(ctx, xrpcc, &atproto.AdminReverseModerationAction_Input{ - CreatedBy: adminUser, - Id: act.Id, - Reason: "reverting for takedown", - }) - if err != nil { - return fmt.Errorf("failed to revert existing action: %w", err) + for _, act := range resp.Actions { + if act.Action == nil || *act.Action != "com.atproto.admin.defs#acknowledge" { + return fmt.Errorf("will only revert acknowledge actions") + } + + _, err := atproto.AdminReverseModerationAction(ctx, xrpcc, &atproto.AdminReverseModerationAction_Input{ + CreatedBy: adminUser, + Id: act.Id, + Reason: "reverting for takedown", + }) + if err != nil { + return fmt.Errorf("failed to revert existing action: %w", err) + } } - } - } + } - resp, err := atproto.AdminTakeModerationAction(ctx, xrpcc, &atproto.AdminTakeModerationAction_Input{ - Action: "com.atproto.admin.defs#takedown", - Reason: reason, - CreatedBy: adminUser, - Subject: &atproto.AdminTakeModerationAction_Input_Subject{ - AdminDefs_RepoRef: &atproto.AdminDefs_RepoRef{ - Did: did, + resp, err := atproto.AdminTakeModerationAction(ctx, xrpcc, &atproto.AdminTakeModerationAction_Input{ + Action: "com.atproto.admin.defs#takedown", + Reason: reason, + CreatedBy: adminUser, + Subject: &atproto.AdminTakeModerationAction_Input_Subject{ + AdminDefs_RepoRef: &atproto.AdminDefs_RepoRef{ + Did: did, + }, }, - }, - }) - if err != nil { - return err - } + }) + if err != nil { + return err + } - b, err := json.MarshalIndent(resp, "", " ") - if err != nil { - return err - } + b, err := json.MarshalIndent(resp, "", " ") + if err != nil { + return err + } - fmt.Println(string(b)) + fmt.Println(string(b)) + } return nil }, }