From d75bbcf9a7fe589f119b103d357ffa874008ab07 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sat, 2 May 2020 16:48:51 +0200 Subject: Option 'body' --- internal/feed/mail.go | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'internal/feed') 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 = "\n" - body = item.Item.Content - } else if item.Item.Description != "" { - comment = "\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 = "
" + comment + body + item.Body = "
" + body } return } @@ -271,5 +280,5 @@ func (feed *Feed) buildBody(item *feeditem) { } } - item.Body = comment + body + item.Body = body } -- cgit v1.2.3-54-g00ecf