Browse Source

Review comments

kegan/feedreader
Kegan Dougal 8 years ago
parent
commit
7b4448957b
  1. 13
      src/github.com/matrix-org/go-neb/services/feedreader/feedreader.go

13
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) frService, ok := s.(*feedReaderService)
if !ok { if !ok {
logger.Error("FeedReader: OnPoll called without an Feed Service instance")
logger.Error("FeedReader: OnPoll called without a Feed Service instance")
return return
} }
now := time.Now().Unix() // Second resolution 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 // Query each feed and send new items to subscribed rooms
for _, u := range pollFeeds { for _, u := range pollFeeds {
feed, items, err := p.queryFeed(frService, u) 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 { if _, err := database.GetServiceDB().StoreService(frService); err != nil {
logger.WithError(err).Error("Failed to persist next poll times for service") 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_id": s.ServiceID(),
"service_type": s.ServiceType(), "service_type": s.ServiceType(),
}) })
logger.Info("Deleting service (0 feeds)")
logger.Info("Deleting service: No feeds remaining.")
polling.StopPolling(s) polling.StopPolling(s)
if err := database.GetServiceDB().DeleteService(s.ServiceID()); err != nil { if err := database.GetServiceDB().DeleteService(s.ServiceID()); err != nil {
logger.WithError(err).Error("Failed to delete service") logger.WithError(err).Error("Failed to delete service")

Loading…
Cancel
Save