mirror of
https://github.com/miniflux/v2.git
synced 2025-06-27 16:36:00 +00:00
Fever API: fix max_id argument logic to follow the specs
This commit is contained in:
parent
5ac55518ab
commit
bf443a65e2
1 changed files with 25 additions and 19 deletions
|
@ -246,27 +246,33 @@ func (h *handler) handleItems(w http.ResponseWriter, r *http.Request) {
|
||||||
builder.WithOrder("id")
|
builder.WithOrder("id")
|
||||||
builder.WithDirection(model.DefaultSortingDirection)
|
builder.WithDirection(model.DefaultSortingDirection)
|
||||||
|
|
||||||
sinceID := request.QueryIntParam(r, "since_id", 0)
|
switch {
|
||||||
if sinceID > 0 {
|
case request.HasQueryParam(r, "since_id"):
|
||||||
builder.AfterEntryID(int64(sinceID))
|
sinceID := request.QueryInt64Param(r, "since_id", 0)
|
||||||
}
|
if sinceID > 0 {
|
||||||
|
builder.AfterEntryID(sinceID)
|
||||||
maxID := request.QueryIntParam(r, "max_id", 0)
|
|
||||||
if maxID > 0 {
|
|
||||||
builder.WithOffset(maxID)
|
|
||||||
}
|
|
||||||
|
|
||||||
csvItemIDs := request.QueryStringParam(r, "with_ids", "")
|
|
||||||
if csvItemIDs != "" {
|
|
||||||
var itemIDs []int64
|
|
||||||
|
|
||||||
for _, strItemID := range strings.Split(csvItemIDs, ",") {
|
|
||||||
strItemID = strings.TrimSpace(strItemID)
|
|
||||||
itemID, _ := strconv.Atoi(strItemID)
|
|
||||||
itemIDs = append(itemIDs, int64(itemID))
|
|
||||||
}
|
}
|
||||||
|
case request.HasQueryParam(r, "max_id"):
|
||||||
|
maxID := request.QueryInt64Param(r, "max_id", 0)
|
||||||
|
if maxID == 0 {
|
||||||
|
builder.WithDirection("desc")
|
||||||
|
} else if maxID > 0 {
|
||||||
|
builder.BeforeEntryID(maxID)
|
||||||
|
builder.WithDirection("desc")
|
||||||
|
}
|
||||||
|
case request.HasQueryParam(r, "with_ids"):
|
||||||
|
csvItemIDs := request.QueryStringParam(r, "with_ids", "")
|
||||||
|
if csvItemIDs != "" {
|
||||||
|
var itemIDs []int64
|
||||||
|
|
||||||
builder.WithEntryIDs(itemIDs)
|
for _, strItemID := range strings.Split(csvItemIDs, ",") {
|
||||||
|
strItemID = strings.TrimSpace(strItemID)
|
||||||
|
itemID, _ := strconv.ParseInt(strItemID, 10, 64)
|
||||||
|
itemIDs = append(itemIDs, itemID)
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.WithEntryIDs(itemIDs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entries, err := builder.GetEntries()
|
entries, err := builder.GetEntries()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue