aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/mail.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-25 20:33:06 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-25 20:33:06 +0200
commitdae31bb0192e6b519111d3cb80ddd4312cda306c (patch)
tree132f610d3e2d71ec396f6a3cd960ac33aad35df2 /internal/feed/mail.go
parent3cbf95d38b6f8bd17b4312371ed07e6847ff0f5c (diff)
downloadfeed2imap-go-dae31bb0192e6b519111d3cb80ddd4312cda306c.tar.gz
feed2imap-go-dae31bb0192e6b519111d3cb80ddd4312cda306c.tar.bz2
feed2imap-go-dae31bb0192e6b519111d3cb80ddd4312cda306c.zip
'Exec' as an alternative to 'Url'
Diffstat (limited to 'internal/feed/mail.go')
-rw-r--r--internal/feed/mail.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/internal/feed/mail.go b/internal/feed/mail.go
index c03a27b..55cb569 100644
--- a/internal/feed/mail.go
+++ b/internal/feed/mail.go
@@ -251,9 +251,19 @@ func getBody(content, description string, bodyCfg config.Body) string {
func (item *item) buildBody() {
feed := item.feed
- feedUrl, err := url.Parse(feed.Url)
- if err != nil {
- panic(fmt.Sprintf("URL '%s' of feed '%s' is not a valid URL. How have we ended up here?", feed.Url, feed.Name))
+
+ var feedUrl *url.URL
+ var err error
+ if feed.Url != "" {
+ feedUrl, err = url.Parse(feed.Url)
+ if err != nil {
+ panic(fmt.Sprintf("URL '%s' of feed '%s' is not a valid URL. How have we ended up here?", feed.Url, feed.Name))
+ }
+ } else if feed.feed.Link != "" {
+ feedUrl, err = url.Parse(feed.feed.Link)
+ if err != nil {
+ panic(fmt.Sprintf("Link '%s' of feed '%s' is not a valid URL.", feed.feed.Link, feed.Name))
+ }
}
body := getBody(item.Content, item.Description, feed.Body)
@@ -288,13 +298,15 @@ func (item *item) buildBody() {
return
}
- srcUrl, err := url.Parse(src)
+ imgUrl, err := url.Parse(src)
if err != nil {
log.Errorf("Feed %s: Item %s: Error parsing URL '%s' embedded in item: %s",
feed.Name, item.Link, src, err)
return
}
- imgUrl := feedUrl.ResolveReference(srcUrl)
+ if feedUrl != nil {
+ imgUrl = feedUrl.ResolveReference(imgUrl)
+ }
img, mime, err := getImage(imgUrl.String(), feed.Global.Timeout, feed.NoTLS)
if err != nil {
René 'Necoro' Neumann1-5/+44 2020-05-10Ignore 'dist' folder and build productsRené 'Necoro' Neumann1-0/+2 2020-05-08Print item hashes in debug modeRené 'Necoro' Neumann1-1/+7 2020-05-07Improve html renderingRené 'Necoro' Neumann2-53/+32 2020-05-07Do not assume items to be new when their published date is newer than the las...René 'Necoro' Neumann2-7/+1 2020-05-07Updating some depsRené 'Necoro' Neumann2-2/+7 2020-05-07Better detection if a text starts with html or notRené 'Necoro' Neumann2-4/+13 2020-05-07go fmtRené 'Necoro' Neumann1-3/+2 2020-05-07Add header X-Feed2Imap-GUIDRené 'Necoro' Neumann3-1/+7 2020-05-07update changelogRené 'Necoro' Neumann1-0/+1 2020-05-07FixRené 'Necoro' Neumann1-1/+1 2020-05-07Unified publishedDate and updatedDate into one (just as the old feed2imap...)René 'Necoro' Neumann5-21/+32 2020-05-06Print version during startupRené 'Necoro' Neumann1-1/+1 2020-05-06Improve templateRené 'Necoro' Neumann3-20/+28 2020-05-05Fix pipelineRené 'Necoro' Neumann1-2/+5 2020-05-05Make changelog a part of the release pipeline (untested)René 'Necoro' Neumann2-0/+12