diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-05-02 16:48:51 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-05-02 16:48:51 +0200 |
commit | d75bbcf9a7fe589f119b103d357ffa874008ab07 (patch) | |
tree | 9f5b27e5e9c48e3d0e5acd5bf6f16f60f47b6b29 /internal/feed/mail.go | |
parent | 3e219c232c0bb4a64f615c599473c959691e6319 (diff) | |
download | feed2imap-go-d75bbcf9a7fe589f119b103d357ffa874008ab07.tar.gz feed2imap-go-d75bbcf9a7fe589f119b103d357ffa874008ab07.tar.bz2 feed2imap-go-d75bbcf9a7fe589f119b103d357ffa874008ab07.zip |
Option 'body'
Diffstat (limited to 'internal/feed/mail.go')
-rw-r--r-- | internal/feed/mail.go | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/internal/feed/mail.go b/internal/feed/mail.go index 297aeff..4b0e38b 100644 --- a/internal/feed/mail.go +++ b/internal/feed/mail.go @@ -209,20 +209,29 @@ func cidNr(idx int) string { return fmt.Sprintf("cid_%d", idx) } -func (feed *Feed) buildBody(item *feeditem) { - var body string - var comment string - - if item.Item.Content != "" { - comment = "<!-- Content -->\n" - body = item.Item.Content - } else if item.Item.Description != "" { - comment = "<!-- Description -->\n" - body = item.Item.Description +func getBody(content, description string, bodyCfg config.Body) string { + switch bodyCfg { + case "default": + if content != "" { + return content + } + return description + case "description": + return description + case "content": + return content + case "both": + return description + content + default: + panic(fmt.Sprintf("Unknown value for Body: %v", bodyCfg)) } +} + +func (feed *Feed) buildBody(item *feeditem) { + body := getBody(item.Item.Content, item.Item.Description, feed.Body) if !feed.InclImages { - item.Body = comment + body + item.Body = body return } @@ -230,7 +239,7 @@ func (feed *Feed) buildBody(item *feeditem) { if err != nil { log.Debugf("Feed %s: Error while parsing html content: %s", feed.Name, err) if body != "" { - item.Body = "<br />" + comment + body + item.Body = "<br />" + body } return } @@ -271,5 +280,5 @@ func (feed *Feed) buildBody(item *feeditem) { } } - item.Body = comment + body + item.Body = body } |