aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/cache_v1.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-07 00:13:34 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-07 00:13:34 +0200
commit345887f3c8319c6dd91f20cd75615fd5c9fcf460 (patch)
tree7adb89358d95067d46cf011771502984b9002b3a /internal/feed/cache_v1.go
parent1bb9b56b214128cd98aabe66b41d0a05da3a0b05 (diff)
downloadfeed2imap-go-345887f3c8319c6dd91f20cd75615fd5c9fcf460.tar.gz
feed2imap-go-345887f3c8319c6dd91f20cd75615fd5c9fcf460.tar.bz2
feed2imap-go-345887f3c8319c6dd91f20cd75615fd5c9fcf460.zip
Unified publishedDate and updatedDate into one (just as the old feed2imap...)
Diffstat (limited to 'internal/feed/cache_v1.go')
-rw-r--r--internal/feed/cache_v1.go31
1 files changed, 13 insertions, 18 deletions
diff --git a/internal/feed/cache_v1.go b/internal/feed/cache_v1.go
index e2562c3..18b12c3 100644
--- a/internal/feed/cache_v1.go
+++ b/internal/feed/cache_v1.go
@@ -41,14 +41,13 @@ type cachedFeed struct {
type itemHash [sha256.Size]byte
type cachedItem struct {
- Guid string
- Title string
- Link string
- PublishedDate time.Time
- UpdatedDate time.Time
- UpdatedCache time.Time
- Hash itemHash
- ID uuid.UUID
+ Guid string
+ Title string
+ Link string
+ Date time.Time
+ UpdatedCache time.Time
+ Hash itemHash
+ ID uuid.UUID
}
func (item cachedItem) String() string {
@@ -56,9 +55,8 @@ func (item cachedItem) String() string {
Title: %q
Guid: %q
Link: %q
- Published: %s
- Updated: %s
-}`, item.Title, item.Guid, item.Link, util.TimeFormat(item.PublishedDate), util.TimeFormat(item.UpdatedDate))
+ Date: %s
+}`, item.Title, item.Guid, item.Link, util.TimeFormat(item.Date))
}
func (cf *cachedFeed) Checked(withFailure bool) {
@@ -159,11 +157,8 @@ func (item *item) newCachedItem() cachedItem {
ci.ID = item.itemId
ci.Title = item.Item.Title
ci.Link = item.Item.Link
- if item.Item.PublishedParsed != nil {
- ci.PublishedDate = *item.Item.PublishedParsed
- }
- if item.Item.UpdatedParsed != nil && !item.Item.UpdatedParsed.Equal(ci.PublishedDate) {
- ci.UpdatedDate = *item.Item.UpdatedParsed
+ if item.DateParsed() != nil {
+ ci.Date = *item.DateParsed()
}
ci.Guid = item.Item.GUID
@@ -176,7 +171,7 @@ func (item *item) newCachedItem() cachedItem {
func (item *cachedItem) similarTo(other *cachedItem, ignoreHash bool) bool {
return other.Title == item.Title &&
other.Link == item.Link &&
- other.PublishedDate.Equal(item.PublishedDate) &&
+ other.Date.Equal(item.Date) &&
(ignoreHash || other.Hash == item.Hash)
}
@@ -215,7 +210,7 @@ func (cf *cachedFeed) filterItems(items []item, ignoreHash, alwaysNew bool) []it
CACHE_ITEMS:
for ci, item := range cacheItems {
log.Debugf("Now checking %s", ci)
- if cf.LastCheck.IsZero() || ci.PublishedDate.After(cf.LastCheck) {
+ if cf.LastCheck.IsZero() || ci.Date.After(cf.LastCheck) {
log.Debug("Newer than last check, including.")
item.addReason("time")