Add author from h-feed to children
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2018-12-30 10:15:14 +01:00
parent 2d1be88dd1
commit 5afdd56bb1
Signed by: peter
GPG Key ID: 374322D56E5209E8

View File

@ -85,7 +85,7 @@ func itemPtr(item *microsub.Item, key string) *[]string {
return nil
}
func simplifyToItem(itemType string, item map[string][]interface{}) microsub.Item {
func simplifyToItem(itemType string, item map[string][]interface{}, author microsub.Card) microsub.Item {
var feedItem microsub.Item
if itemType == "cite" {
@ -94,6 +94,8 @@ func simplifyToItem(itemType string, item map[string][]interface{}) microsub.Ite
feedItem.Type = itemType
feedItem.Refs = make(map[string]microsub.Item)
hasAuthor := false
for k, v := range item {
switch k {
case "bookmark-of", "like-of", "repost-of", "in-reply-to":
@ -111,6 +113,7 @@ func simplifyToItem(itemType string, item map[string][]interface{}) microsub.Ite
case "author":
author, _ := simplifyCard(v[0])
feedItem.Author = &author
hasAuthor = true
case "checkin", "location":
author, _ := simplifyCard(v[0])
feedItem.Checkin = &author
@ -156,6 +159,10 @@ func simplifyToItem(itemType string, item map[string][]interface{}) microsub.Ite
}
}
if !hasAuthor {
feedItem.Author = &author
}
return feedItem
}
@ -235,7 +242,7 @@ func SimplifyMicroformatItem(mdItem *microformats.Microformat, author microsub.C
return item, false
}
return simplifyToItem(itemType, mdItem.Properties), true
return simplifyToItem(itemType, mdItem.Properties, author), true
}
func hasType(item *microformats.Microformat, itemType string) bool {