Skip to content

Commit

Permalink
Prefer GUIDs to Timestamps.
Browse files Browse the repository at this point in the history
Preserves timestamps as a fallback since not every feed has GUIDs for
their items.
  • Loading branch information
c-14 committed Jun 8, 2017
1 parent 6b1d9bd commit 0ebfbb3
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,28 +91,20 @@ func fetchFeed(fp FeedParser, feedName string, account *RSSFeed, config *config.
account.GUIDList = make(map[string]struct{})
}
for _, item := range feed.Items {
_, exists := guids[item.GUID]
date, newer := hasNewerDate(item, account.LastFetched)
if newer == DateNewer {
if !exists || (item.GUID == "" && newer == DateNewer) {
e := createEmail(feedName, feed.Title, item, date, account.config, config)
err = e.Send(fp.messages)
if err != nil {
break
}
} else if newer == NoDate {
_, exists := guids[item.GUID]
if !exists {
e := createEmail(feedName, feed.Title, item, date, account.config, config)
err = e.Send(fp.messages)
}
if err == nil {
account.GUIDList[item.GUID] = struct{}{}
} else {
break
}
}
if err == nil {
account.GUIDList[item.GUID] = struct{}{}
} else {
break
}
}
if err == nil {
account.LastFetched = account.LastQueried
account.LastFetched = time.Now().Unix()
}

<-fp.sem
Expand Down

0 comments on commit 0ebfbb3

Please sign in to comment.