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)
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")

Loading…
Cancel
Save