aboutsummaryrefslogtreecommitdiffstats
path: root/api/api.go
diff options
context:
space:
mode:
authorAdam Mathes <adam@adammathes.com>2026-02-15 14:09:39 -0800
committerAdam Mathes <adam@adammathes.com>2026-02-15 14:09:39 -0800
commit1d3ad564df8cc09b16172901916bcef9abe31ab4 (patch)
tree342ebced54435226c71bc720e2275edc3894bc24 /api/api.go
parentd176a6b6b79b76f2324a356abda4ac254ec4fc29 (diff)
downloadneko-1d3ad564df8cc09b16172901916bcef9abe31ab4.tar.gz
neko-1d3ad564df8cc09b16172901916bcef9abe31ab4.tar.bz2
neko-1d3ad564df8cc09b16172901916bcef9abe31ab4.zip
Backend: Support multi-feed filtering in stream API
Diffstat (limited to 'api/api.go')
-rw-r--r--api/api.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/api/api.go b/api/api.go
index 6833ce4..16e8dd6 100644
--- a/api/api.go
+++ b/api/api.go
@@ -60,13 +60,22 @@ func (s *Server) HandleStream(w http.ResponseWriter, r *http.Request) {
}
maxID, _ := strconv.ParseInt(r.FormValue("max_id"), 10, 64)
- feedID, _ := strconv.ParseInt(r.FormValue("feed_id"), 10, 64)
- // Backward compatibility with feed_url if feed_id is not provided
- if feedID == 0 && r.FormValue("feed_url") != "" {
+ var feedIDs []int64
+ if idsStr := r.FormValue("feed_ids"); idsStr != "" {
+ for _, idStr := range strings.Split(idsStr, ",") {
+ if id, err := strconv.ParseInt(idStr, 10, 64); err == nil {
+ feedIDs = append(feedIDs, id)
+ }
+ }
+ } else if feedID, _ := strconv.ParseInt(r.FormValue("feed_id"), 10, 64); feedID != 0 {
+ feedIDs = []int64{feedID}
+ } else if r.FormValue("feed_url") != "" {
var f feed.Feed
_ = f.ByUrl(r.FormValue("feed_url"))
- feedID = f.Id
+ if f.Id != 0 {
+ feedIDs = []int64{f.Id}
+ }
}
category := r.FormValue("tag")
@@ -78,7 +87,7 @@ func (s *Server) HandleStream(w http.ResponseWriter, r *http.Request) {
unreadOnly = false
}
- items, err := item.Filter(maxID, feedID, category, unreadOnly, starredOnly, 0, searchQuery)
+ items, err := item.Filter(maxID, feedIDs, category, unreadOnly, starredOnly, 0, searchQuery)
if err != nil {
log.Println(err)
jsonError(w, "failed to filter items", http.StatusInternalServerError)