Skip to content

Commit

Permalink
fix(admin): validate request param (#9)
Browse files Browse the repository at this point in the history
Ensure we have an ID before attempting to delete
  • Loading branch information
bndw authored Aug 9, 2023
1 parent 04a2773 commit 4734210
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@ func adminDeleteHandler(cfg Config, db relayer.Storage) func(http.ResponseWriter

var (
id = r.URL.Query().Get("id")
pk = r.URL.Query().Get("pubkey")
)

filter := nostr.Filter{}
if id != "" {
filter.IDs = []string{id}
}
if pk != "" {
filter.Authors = []string{pk}

if len(filter.IDs) == 0 {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("must provide id param"))
return
}

ctx := context.Background()
Expand Down

0 comments on commit 4734210

Please sign in to comment.