aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/parse.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-22 22:54:43 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-22 22:54:43 +0100
commit7106d5a6e7585dce5fdd552cca30063dd352dc23 (patch)
tree88a9cb7150f86fcadb8f87e3a6d0892bf68c2251 /internal/feed/parse.go
parentfb2aa9b1f04d509c8215c1fa6505a144482c343d (diff)
downloadfeed2imap-go-7106d5a6e7585dce5fdd552cca30063dd352dc23.tar.gz
feed2imap-go-7106d5a6e7585dce5fdd552cca30063dd352dc23.tar.bz2
feed2imap-go-7106d5a6e7585dce5fdd552cca30063dd352dc23.zip
Split cache and feed packages
Diffstat (limited to 'internal/feed/parse.go')
-rw-r--r--internal/feed/parse.go20
1 files changed, 3 insertions, 17 deletions
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index b08c286..a2812bd 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -9,10 +9,9 @@ import (
"github.com/mmcdole/gofeed"
"github.com/Necoro/feed2imap-go/internal/http"
- "github.com/Necoro/feed2imap-go/pkg/log"
)
-func (feed *Feed) parse() error {
+func (feed *Feed) Parse() error {
fp := gofeed.NewParser()
var reader io.Reader
@@ -58,22 +57,9 @@ func (feed *Feed) parse() error {
}
feed.feed = parsedFeed
- feed.items = make([]item, len(parsedFeed.Items))
+ feed.items = make([]Item, len(parsedFeed.Items))
for idx, feedItem := range parsedFeed.Items {
- feed.items[idx] = item{Feed: parsedFeed, Item: feedItem, itemId: uuid.New(), feed: feed}
+ feed.items[idx] = Item{Feed: parsedFeed, feed: feed, Item: feedItem, ID: uuid.New()}
}
return cleanup()
}
-
-func handleFeed(feed *Feed) {
- log.Printf("Fetching %s from %s", feed.Name, feed.Url)
-
- err := feed.parse()
- if err != nil {
- if feed.Url == "" || feed.cached.Failures() >= feed.Global.MaxFailures {
- log.Error(err)
- } else {
- log.Print(err)
- }
- }
-}