diff --git a/cmd/gosky/bgs.go b/cmd/gosky/bgs.go index 727f56f31..dfbddb680 100644 --- a/cmd/gosky/bgs.go +++ b/cmd/gosky/bgs.go @@ -33,6 +33,7 @@ var bgsAdminCmd = &cli.Command{ bgsSetNewSubsEnabledCmd, bgsCompactRepo, bgsCompactAll, + bgsResetRepo, }, } @@ -381,3 +382,44 @@ var bgsCompactAll = &cli.Command{ return nil }, } + +var bgsResetRepo = &cli.Command{ + Name: "reset-repo", + Action: func(cctx *cli.Context) error { + url := cctx.String("bgs") + "/admin/repo/reset" + + did := cctx.Args().First() + url += fmt.Sprintf("?did=%s", did) + + req, err := http.NewRequest("POST", url, nil) + if err != nil { + return err + } + + auth := cctx.String("key") + req.Header.Set("Authorization", "Bearer "+auth) + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return err + } + + if resp.StatusCode != 200 { + var e xrpc.XRPCError + if err := json.NewDecoder(resp.Body).Decode(&e); err != nil { + return err + } + + return &e + } + + var out map[string]any + if err := json.NewDecoder(resp.Body).Decode(&out); err != nil { + return err + } + + fmt.Println(out) + + return nil + }, +}