From ddd2bacbaeecfc4bf3b157ecdd0c8fc42ee2f275 Mon Sep 17 00:00:00 2001 From: Alexander Weinhold Date: Tue, 8 Aug 2017 23:48:56 +0200 Subject: [PATCH] be less pessimistic about errors --- libUnreadMail.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libUnreadMail.go b/libUnreadMail.go index 08a6670..e008807 100644 --- a/libUnreadMail.go +++ b/libUnreadMail.go @@ -149,17 +149,15 @@ func Fetch(p *Parameters) ([]*mail.Message, []error) { func FetchPlaintext(p *Parameters) ([]string, []error) { mails, errs := Fetch(p) mailsPlain := make([]string, 0) - if len(errs) == 0 { - for _, mail := range mails { - // check for mime parts - parts, pErrs := getPlainParts(mail) - errs = append(errs, pErrs...) - date := mail.Header.Get("Date") - from := mail.Header.Get("From") - subject := mail.Header.Get("Subject") - m := fmt.Sprintf("Date: %s\nFrom: %s\nSubject: %s\n\n%s", date, from, subject, strings.Join(parts, "\n\n")) - mailsPlain = append(mailsPlain, m) - } + for _, mail := range mails { + // check for mime parts + parts, pErrs := getPlainParts(mail) + errs = append(errs, pErrs...) + date := mail.Header.Get("Date") + from := mail.Header.Get("From") + subject := mail.Header.Get("Subject") + m := fmt.Sprintf("Date: %s\nFrom: %s\nSubject: %s\n\n%s", date, from, subject, strings.Join(parts, "\n\n")) + mailsPlain = append(mailsPlain, m) } return mailsPlain, errs }