mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-17 13:24:56 +00:00
fix single entry rss feed
This commit is contained in:
@@ -114,9 +114,9 @@ func (e *Rss) Feed(ctx context.Context, req *pb.FeedRequest, rsp *pb.FeedRespons
|
|||||||
|
|
||||||
// feeds by url
|
// feeds by url
|
||||||
feedUrls := map[string]bool{}
|
feedUrls := map[string]bool{}
|
||||||
|
var feed *pb.Feed
|
||||||
|
|
||||||
if len(req.Name) > 0 {
|
if len(req.Name) > 0 {
|
||||||
feed := new(pb.Feed)
|
|
||||||
id := tenantID + "/" + idFromName(req.Name)
|
id := tenantID + "/" + idFromName(req.Name)
|
||||||
q := model.QueryEquals("ID", id)
|
q := model.QueryEquals("ID", id)
|
||||||
|
|
||||||
@@ -124,6 +124,8 @@ func (e *Rss) Feed(ctx context.Context, req *pb.FeedRequest, rsp *pb.FeedRespons
|
|||||||
if err := e.feeds.Read(q, feed); err != nil {
|
if err := e.feeds.Read(q, feed); err != nil {
|
||||||
return errors.InternalServerError("rss.feeds", "could not read feed")
|
return errors.InternalServerError("rss.feeds", "could not read feed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
feedUrls[feed.Url] = true
|
||||||
} else {
|
} else {
|
||||||
// get all the feeds for a user
|
// get all the feeds for a user
|
||||||
var feeds []*pb.Feed
|
var feeds []*pb.Feed
|
||||||
@@ -143,7 +145,15 @@ func (e *Rss) Feed(ctx context.Context, req *pb.FeedRequest, rsp *pb.FeedRespons
|
|||||||
req.Limit = int64(25)
|
req.Limit = int64(25)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// default query all
|
||||||
q := model.QueryAll()
|
q := model.QueryAll()
|
||||||
|
|
||||||
|
// if the need is not nil, then use one url
|
||||||
|
if feed != nil {
|
||||||
|
q = e.entriesURLIndex.ToQuery(feed.Url)
|
||||||
|
}
|
||||||
|
|
||||||
q.Limit = req.Limit
|
q.Limit = req.Limit
|
||||||
q.Offset = req.Offset
|
q.Offset = req.Offset
|
||||||
|
|
||||||
@@ -155,6 +165,7 @@ func (e *Rss) Feed(ctx context.Context, req *pb.FeedRequest, rsp *pb.FeedRespons
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.InternalServerError("rss.feeds", "could not read feed")
|
return errors.InternalServerError("rss.feeds", "could not read feed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the relevant entries
|
// find the relevant entries
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
// check its a url we care about
|
// check its a url we care about
|
||||||
|
|||||||
Reference in New Issue
Block a user