mirror of https://github.com/miniflux/v2.git
API: Add the possibility to filter entries by category ID
This commit is contained in:
parent
04c4890124
commit
d9f52bb634
10
api/entry.go
10
api/entry.go
|
@ -138,7 +138,15 @@ func (h *handler) getEntries(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
builder := h.store.NewEntryQueryBuilder(request.UserID(r))
|
userID := request.UserID(r)
|
||||||
|
categoryID := request.QueryInt64Param(r, "category_id", 0)
|
||||||
|
if categoryID > 0 && !h.store.CategoryExists(userID, categoryID) {
|
||||||
|
json.BadRequest(w, r, errors.New("Invalid category ID"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
builder := h.store.NewEntryQueryBuilder(userID)
|
||||||
|
builder.WithCategoryID(categoryID)
|
||||||
builder.WithStatuses(statuses)
|
builder.WithStatuses(statuses)
|
||||||
builder.WithOrder(order)
|
builder.WithOrder(order)
|
||||||
builder.WithDirection(direction)
|
builder.WithDirection(direction)
|
||||||
|
|
Loading…
Reference in New Issue