From 7b4448957b17308507132c27660f11eac5f4f883 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 5 Oct 2016 14:06:23 +0100 Subject: [PATCH] Review comments --- .../go-neb/services/feedreader/feedreader.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/github.com/matrix-org/go-neb/services/feedreader/feedreader.go b/src/github.com/matrix-org/go-neb/services/feedreader/feedreader.go index 8612c31..0819ce2 100644 --- a/src/github.com/matrix-org/go-neb/services/feedreader/feedreader.go +++ b/src/github.com/matrix-org/go-neb/services/feedreader/feedreader.go @@ -26,7 +26,7 @@ func (p *feedPoller) OnPoll(s types.Service, cli *matrix.Client) { frService, ok := s.(*feedReaderService) if !ok { - logger.Error("FeedReader: OnPoll called without an Feed Service instance") + logger.Error("FeedReader: OnPoll called without a Feed Service instance") return } now := time.Now().Unix() // Second resolution @@ -40,6 +40,10 @@ func (p *feedPoller) OnPoll(s types.Service, cli *matrix.Client) { } } + if len(pollFeeds) == 0 { + return + } + // Query each feed and send new items to subscribed rooms for _, u := range pollFeeds { feed, items, err := p.queryFeed(frService, u) @@ -60,10 +64,7 @@ func (p *feedPoller) OnPoll(s types.Service, cli *matrix.Client) { } } - // Persist the service to save the next poll times if we did some queries - if len(pollFeeds) == 0 { - return - } + // Persist the service to save the next poll times if _, err := database.GetServiceDB().StoreService(frService); err != nil { logger.WithError(err).Error("Failed to persist next poll times for service") } @@ -216,7 +217,7 @@ func (s *feedReaderService) PostRegister(oldService types.Service) { "service_id": s.ServiceID(), "service_type": s.ServiceType(), }) - logger.Info("Deleting service (0 feeds)") + logger.Info("Deleting service: No feeds remaining.") polling.StopPolling(s) if err := database.GetServiceDB().DeleteService(s.ServiceID()); err != nil { logger.WithError(err).Error("Failed to delete service")