Skip to content

Commit

Permalink
add commands for deleting accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Oct 4, 2023
1 parent 8a63a7a commit 876a9f4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/gosky/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ var checkUserCmd = &cli.Command{
} else {
handle, _, err := api.ResolveDidToHandle(ctx, xrpcc, plcc, phr, fa)
if err != nil {
return fmt.Errorf("resolve did %q: %w", fa, err)
fmt.Println("ERROR: failed to resolve inviter: ", err)
handle = fa
}

invby = handle
Expand Down
44 changes: 43 additions & 1 deletion cmd/gosky/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func run(args []string) {
refreshAuthTokenCmd,
syncCmd,
listAllPostsCmd,
deletePostCmd,
getNotificationsCmd,
followsCmd,
resetPasswordCmd,
Expand All @@ -105,6 +104,8 @@ func run(args []string) {
adminCmd,
createFeedGeneratorCmd,
rebaseRepoCmd,
requestAccountDeletionCmd,
deleteAccountCmd,
}

app.RunAndExitOnError()
Expand Down Expand Up @@ -1566,3 +1567,44 @@ var rebaseRepoCmd = &cli.Command{
return nil
},
}

var requestAccountDeletionCmd = &cli.Command{
Name: "request-account-deletion",
Action: func(cctx *cli.Context) error {
xrpcc, err := cliutil.GetXrpcClient(cctx, false)
if err != nil {
return err
}

err = comatproto.ServerRequestAccountDelete(context.TODO(), xrpcc)
if err != nil {
return err
}

return nil
},
}

var deleteAccountCmd = &cli.Command{
Name: "delete-account",
Action: func(cctx *cli.Context) error {
xrpcc, err := cliutil.GetXrpcClient(cctx, false)
if err != nil {
return err
}

token := cctx.Args().First()
password := cctx.Args().Get(1)

err = comatproto.ServerDeleteAccount(context.TODO(), xrpcc, &comatproto.ServerDeleteAccount_Input{
Did: xrpcc.Auth.Did,
Token: token,
Password: password,
})
if err != nil {
return err
}

return nil
},
}

0 comments on commit 876a9f4

Please sign in to comment.