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