Compare commits

..

No commits in common. "e545f796ee9f83e4edc2b8393b935a7e103b9ab7" and "5a2f6b184463ffb5b0337dec31da9b0b86abe39d" have entirely different histories.

View File

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