Skip to content

Commit

Permalink
Make the feed category optional for API clients who don't support cat…
Browse files Browse the repository at this point in the history
…egories
  • Loading branch information
fguillot committed Oct 6, 2023
1 parent 67eb574 commit 275d8ea
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/api/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ func (h *handler) createFeed(w http.ResponseWriter, r *http.Request) {
return
}

// Make the feed category optional for clients who don't support categories.
if feedCreationRequest.CategoryID == 0 {
category, err := h.store.FirstCategory(userID)
if err != nil {
json.ServerError(w, r, err)
return
}
feedCreationRequest.CategoryID = category.ID
}

if validationErr := validator.ValidateFeedCreation(h.store, userID, &feedCreationRequest); validationErr != nil {
json.BadRequest(w, r, validationErr.Error())
return
Expand Down

0 comments on commit 275d8ea

Please sign in to comment.