From 1d3ad564df8cc09b16172901916bcef9abe31ab4 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Sun, 15 Feb 2026 14:09:39 -0800 Subject: Backend: Support multi-feed filtering in stream API --- api/api.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'api/api.go') 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) -- cgit v1.2.3