Include refs in microsub.Item
All checks were successful
the build was successful

This commit is contained in:
Peter Stuifzand 2018-08-05 17:23:50 +02:00
parent 207fd8ecd6
commit 6ed7dc8ddb
Signed by: peter
GPG Key ID: 374322D56E5209E8
2 changed files with 42 additions and 21 deletions

View File

@ -34,7 +34,15 @@ func simplify(itemType string, item map[string][]interface{}) map[string]interfa
for k, v := range item {
if k == "bookmark-of" || k == "like-of" || k == "repost-of" || k == "in-reply-to" {
if value, ok := v[0].(*microformats.Microformat); ok {
if value.Type[0] == "h-cite" {
refs := make(map[string]interface{})
u := value.Properties["url"][0].(string)
refs[u] = SimplifyMicroformat(value)
feedItem["refs"] = refs
feedItem[k] = u
} else {
feedItem[k] = value.Value
}
} else {
feedItem[k] = v
}
@ -216,6 +224,18 @@ func MapToItem(result map[string]interface{}) microsub.Item {
item.Checkin = MapToAuthor(checkin.(map[string]string))
}
if refsValue, e := result["refs"]; e {
if refs, ok := refsValue.(map[string]interface{}); ok {
item.Refs = make(map[string]microsub.Item)
for key, ref := range refs {
refItem := MapToItem(ref.(map[string]interface{}))
refItem.Type = "entry"
item.Refs[key] = refItem
}
}
}
if content, e := result["content"]; e {
itemContent := &microsub.Content{}
set := false

View File

@ -75,6 +75,7 @@ type Item struct {
Latitude string `json:"latitude,omitempty"`
Longitude string `json:"longitude,omitempty"`
Checkin *Card `json:"checkin,omitempty"`
Refs map[string]Item `json:"refs,omitempty"`
ID string `json:"_id,omitempty"`
Read bool `json:"_is_read"`
}