aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/mail.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-27 14:10:09 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-27 14:28:36 +0100
commit6ad93417790d0d63cd889ac65566fc4e4c3e34d1 (patch)
tree799043425accff66f43ec41b38f08d9eff2ea499 /internal/feed/mail.go
parent050ce6e8f89d8d4e126481644023875eb3c6fb2e (diff)
downloadfeed2imap-go-6ad93417790d0d63cd889ac65566fc4e4c3e34d1.tar.gz
feed2imap-go-6ad93417790d0d63cd889ac65566fc4e4c3e34d1.tar.bz2
feed2imap-go-6ad93417790d0d63cd889ac65566fc4e4c3e34d1.zip
Do not use deprecated gofeed.Item.Author, but Authors instead
Diffstat (limited to 'internal/feed/mail.go')
-rw-r--r--internal/feed/mail.go26
1 files changed, 18 insertions, 8 deletions
diff --git a/internal/feed/mail.go b/internal/feed/mail.go
index 636f6a0..6ca7192 100644
--- a/internal/feed/mail.go
+++ b/internal/feed/mail.go
@@ -16,6 +16,7 @@ import (
"github.com/emersion/go-message/mail"
"github.com/gabriel-vasile/mimetype"
"github.com/jaytaylor/html2text"
+ "github.com/mmcdole/gofeed"
"golang.org/x/net/html"
"github.com/Necoro/feed2imap-go/internal/feed/template"
@@ -31,16 +32,25 @@ func address(name, address string) []*mail.Address {
return []*mail.Address{{Name: name, Address: address}}
}
+func author(authors []*gofeed.Person) *gofeed.Person {
+ if len(authors) > 0 {
+ return authors[0]
+ }
+ return nil
+}
+
func (item *Item) fromAddress() []*mail.Address {
+ itemAuthor := author(item.Authors)
+ feedAuthor := author(item.Feed.Authors)
switch {
- case item.Author != nil && item.Author.Email != "":
- return address(item.Author.Name, item.Author.Email)
- case item.Author != nil && item.Author.Name != "":
- return address(item.Author.Name, item.defaultEmail())
- case item.Feed.Author != nil && item.Feed.Author.Email != "":
- return address(item.Feed.Author.Name, item.Feed.Author.Email)
- case item.Feed.Author != nil && item.Feed.Author.Name != "":
- return address(item.Feed.Author.Name, item.defaultEmail())
+ case itemAuthor != nil && itemAuthor.Email != "":
+ return address(itemAuthor.Name, itemAuthor.Email)
+ case itemAuthor != nil && itemAuthor.Name != "":
+ return address(itemAuthor.Name, item.defaultEmail())
+ case feedAuthor != nil && feedAuthor.Email != "":
+ return address(feedAuthor.Name, feedAuthor.Email)
+ case feedAuthor != nil && feedAuthor.Name != "":
+ return address(feedAuthor.Name, item.defaultEmail())
default:
return address(item.feed.Name, item.defaultEmail())
}