1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

Add API parameter to filter entries by category

This commit is contained in:
Frédéric Guillot 2019-11-17 22:53:11 -08:00
parent fad9ad2be4
commit e878dca3d7
6 changed files with 58 additions and 17 deletions

View file

@ -164,7 +164,7 @@ func (h *handler) getEntries(w http.ResponseWriter, r *http.Request) {
func (h *handler) setEntryStatus(w http.ResponseWriter, r *http.Request) {
entryIDs, status, err := decodeEntryStatusPayload(r.Body)
if err != nil {
json.BadRequest(w , r, errors.New("Invalid JSON payload"))
json.BadRequest(w, r, errors.New("Invalid JSON payload"))
return
}
@ -193,25 +193,30 @@ func (h *handler) toggleBookmark(w http.ResponseWriter, r *http.Request) {
func configureFilters(builder *storage.EntryQueryBuilder, r *http.Request) {
beforeEntryID := request.QueryInt64Param(r, "before_entry_id", 0)
if beforeEntryID != 0 {
if beforeEntryID > 0 {
builder.BeforeEntryID(beforeEntryID)
}
afterEntryID := request.QueryInt64Param(r, "after_entry_id", 0)
if afterEntryID != 0 {
if afterEntryID > 0 {
builder.AfterEntryID(afterEntryID)
}
beforeTimestamp := request.QueryInt64Param(r, "before", 0)
if beforeTimestamp != 0 {
if beforeTimestamp > 0 {
builder.BeforeDate(time.Unix(beforeTimestamp, 0))
}
afterTimestamp := request.QueryInt64Param(r, "after", 0)
if afterTimestamp != 0 {
if afterTimestamp > 0 {
builder.AfterDate(time.Unix(afterTimestamp, 0))
}
categoryID := request.QueryInt64Param(r, "category_id", 0)
if categoryID > 0 {
builder.WithCategoryID(categoryID)
}
if request.HasQueryParam(r, "starred") {
builder.WithStarred()
}