Improve JSON feed parsing
This commit is contained in:
parent
fa877ef89b
commit
2818576e2e
|
@ -269,6 +269,7 @@ func (b *memoryBackend) feedItems(fetchURL, contentType string, body io.Reader)
|
|||
|
||||
for _, feedItem := range feed.Items {
|
||||
var item microsub.Item
|
||||
item.Type = "entry"
|
||||
item.Name = feedItem.Title
|
||||
item.Content.HTML = feedItem.ContentHTML
|
||||
item.Content.Text = feedItem.ContentText
|
||||
|
@ -276,7 +277,17 @@ func (b *memoryBackend) feedItems(fetchURL, contentType string, body io.Reader)
|
|||
item.Summary = []string{feedItem.Summary}
|
||||
item.Id = hex.EncodeToString([]byte(feedItem.ID))
|
||||
item.Published = feedItem.DatePublished
|
||||
item.Author = author
|
||||
|
||||
itemAuthor := microsub.Card{}
|
||||
itemAuthor.Type = "card"
|
||||
itemAuthor.Name = feedItem.Author.Name
|
||||
itemAuthor.URL = feedItem.Author.URL
|
||||
itemAuthor.Photo = feedItem.Author.Avatar
|
||||
if itemAuthor.URL != "" {
|
||||
item.Author = itemAuthor
|
||||
} else {
|
||||
item.Author = author
|
||||
}
|
||||
item.Photo = []string{feedItem.Image}
|
||||
items = append(items, item)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ type JSONFeedItem struct {
|
|||
Image string `json:"image,omitempty"`
|
||||
ExternalURL string `json:"external_url,omitempty"`
|
||||
DatePublished string `json:"date_published,omitempty"`
|
||||
Author JSONFeedAuthor `json:"author,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Attachments []JSONFeedAttachment `json:"attachments,omitempty"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user