Improve notifications
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2019-02-16 07:41:03 +01:00
parent e2361daa0e
commit e545f796ee
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -287,18 +287,21 @@ func (b *memoryBackend) run() {
case <-b.ticker.C:
feeds := b.getFeeds()
count := 0
for uid := range feeds {
for _, feedURL := range feeds[uid] {
resp, err := b.Fetch3(uid, feedURL)
if err != nil {
_ = b.channelAddItem("notifications", microsub.Item{
Type: "entry",
Name: fmt.Sprintf("Error while Fetch3 of %s: %v", feedURL, err),
Name: "Error while fetching feed",
Content: &microsub.Content{
Text: "error while fetching feed",
Text: fmt.Sprintf("Error while updating feed %s: %v", feedURL, err),
},
UID: time.Now().String(),
})
count++
log.Printf("Error while Fetch3 of %s: %v\n", feedURL, err)
continue
}
@ -307,6 +310,10 @@ func (b *memoryBackend) run() {
}
}
if count > 0 {
_ = b.updateChannelUnreadCount("notifications")
}
case <-b.quit:
b.ticker.Stop()
return
@ -343,12 +350,13 @@ func (b *memoryBackend) FollowURL(uid string, url string) (microsub.Feed, error)
if err != nil {
_ = b.channelAddItem("notifications", microsub.Item{
Type: "entry",
Name: fmt.Sprintf("Error while Fetch3 of %s: %v", feed.URL, err),
Name: "Error while fetching feed",
Content: &microsub.Content{
Text: "error while fetching feed",
Text: fmt.Sprintf("Error while Fetch3 of %s: %v", feed.URL, err),
},
UID: time.Now().String(),
})
_ = b.updateChannelUnreadCount("notifications")
return feed, err
}
defer resp.Body.Close()