From 66fb3253f74e5c1e9f0859ca6c4c66f7473909c4 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 28 Nov 2016 10:38:58 +0000 Subject: [PATCH] Treat RSS feeds with 0 items as errors In the wild it looks like some RSS feeds will occasionally return 0 items to requests *but not return an error*. This previously meant we would clobber our knowledge of recent GUIDs with the empty set. This meant that the next successful poll would resend the **entire** RSS feed. --- src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go index 21c9b1d..0d21ab3 100644 --- a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go +++ b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go @@ -241,7 +241,9 @@ func (s *Service) queryFeed(feedURL string) (*gofeed.Feed, []gofeed.Item, error) fp := gofeed.NewParser() fp.Client = cachingClient feed, err := fp.ParseURL(feedURL) - if err != nil { + // check for no items in addition to any returned errors as it appears some RSS feeds + // do not consistently return items. + if err != nil || len(feed.Items) == 0 { f := s.Feeds[feedURL] f.IsFailing = true s.Feeds[feedURL] = f