aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-20 01:01:37 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-20 01:01:37 +0200
commitf1231aa444bd13aa031fe6e3dac32138436f956b (patch)
tree9f8bcbc1ca455bd451020c1a4303e11b451dc4ea /internal
parent161dd4405474cc905e6912bab243509a3a6f88db (diff)
downloadfeed2imap-go-f1231aa444bd13aa031fe6e3dac32138436f956b.tar.gz
feed2imap-go-f1231aa444bd13aa031fe6e3dac32138436f956b.tar.bz2
feed2imap-go-f1231aa444bd13aa031fe6e3dac32138436f956b.zip
Feeditems
Diffstat (limited to 'internal')
-rw-r--r--internal/feed/feed.go8
-rw-r--r--internal/feed/parse.go8
2 files changed, 14 insertions, 2 deletions
diff --git a/internal/feed/feed.go b/internal/feed/feed.go
index 59c15f2..cd906a2 100644
--- a/internal/feed/feed.go
+++ b/internal/feed/feed.go
@@ -14,7 +14,13 @@ type Feed struct {
Target []string
Url string
config.Options
- feed gofeed.Feed
+ feed *gofeed.Feed
+ items []feeditem
+}
+
+type feeditem struct {
+ *gofeed.Feed
+ *gofeed.Item
}
type Feeds map[string]*Feed
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index a38be92..00b6aff 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -19,10 +19,16 @@ func parseFeed(feed *Feed) error {
ctx, cancel := context()
defer cancel()
fp := gofeed.NewParser()
- if _, err := fp.ParseURLWithContext(feed.Url, ctx); err != nil {
+ parsedFeed, err := fp.ParseURLWithContext(feed.Url, ctx)
+ if err != nil {
return fmt.Errorf("while fetching %s from %s: %w", feed.Name, feed.Url, err)
}
+ feed.feed = parsedFeed
+ feed.items = make([]feeditem, len(parsedFeed.Items))
+ for _, item := range parsedFeed.Items {
+ feed.items = append(feed.items, feeditem{parsedFeed, item})
+ }
return nil
}