diff options
| author | Adam Mathes <adam@adammathes.com> | 2026-02-15 14:09:39 -0800 |
|---|---|---|
| committer | Adam Mathes <adam@adammathes.com> | 2026-02-15 14:09:39 -0800 |
| commit | 1d3ad564df8cc09b16172901916bcef9abe31ab4 (patch) | |
| tree | 342ebced54435226c71bc720e2275edc3894bc24 /models/item/item.go | |
| parent | d176a6b6b79b76f2324a356abda4ac254ec4fc29 (diff) | |
| download | neko-1d3ad564df8cc09b16172901916bcef9abe31ab4.tar.gz neko-1d3ad564df8cc09b16172901916bcef9abe31ab4.tar.bz2 neko-1d3ad564df8cc09b16172901916bcef9abe31ab4.zip | |
Backend: Support multi-feed filtering in stream API
Diffstat (limited to 'models/item/item.go')
| -rw-r--r-- | models/item/item.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/models/item/item.go b/models/item/item.go index dc277a3..189cb4a 100644 --- a/models/item/item.go +++ b/models/item/item.go @@ -97,7 +97,7 @@ func filterPolicy() *bluemonday.Policy { } func ItemById(id int64) *Item { - items, err := Filter(0, 0, "", false, false, id, "") + items, err := Filter(0, nil, "", false, false, id, "") if err != nil || len(items) == 0 { return nil } @@ -134,7 +134,7 @@ func (i *Item) GetFullContent() { } } -func Filter(max_id int64, feed_id int64, category string, unread_only bool, starred_only bool, item_id int64, search_query string) ([]*Item, error) { +func Filter(max_id int64, feed_ids []int64, category string, unread_only bool, starred_only bool, item_id int64, search_query string) ([]*Item, error) { var args []interface{} tables := " feed,item" @@ -155,9 +155,13 @@ func Filter(max_id int64, feed_id int64, category string, unread_only bool, star args = append(args, max_id) } - if feed_id != 0 { - query = query + " AND feed.id=? " - args = append(args, feed_id) + if len(feed_ids) > 0 { + placeholders := make([]string, len(feed_ids)) + for i := range feed_ids { + placeholders[i] = "?" + args = append(args, feed_ids[i]) + } + query = query + " AND feed.id IN (" + strings.Join(placeholders, ",") + ") " } if category != "" { |
