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 {
feedItem[k] = value.Value
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

@ -57,26 +57,27 @@ type Content struct {
// Item is a post object
type Item struct {
Type string `json:"type"`
Name string `json:"name,omitempty"`
Published string `json:"published,omitempty"`
Updated string `json:"updated,omitempty"`
URL string `json:"url,omitempty"`
UID string `json:"uid,omitempty"`
Author *Card `json:"author,omitempty"`
Category []string `json:"category,omitempty"`
Photo []string `json:"photo,omitempty"`
LikeOf []string `json:"like-of,omitempty"`
BookmarkOf []string `json:"bookmark-of,omitempty"`
RepostOf []string `json:"repost-of,omitempty"`
InReplyTo []string `json:"in-reply-to,omitempty"`
Summary []string `json:"summary,omitempty"`
Content *Content `json:"content,omitempty"`
Latitude string `json:"latitude,omitempty"`
Longitude string `json:"longitude,omitempty"`
Checkin *Card `json:"checkin,omitempty"`
ID string `json:"_id,omitempty"`
Read bool `json:"_is_read"`
Type string `json:"type"`
Name string `json:"name,omitempty"`
Published string `json:"published,omitempty"`
Updated string `json:"updated,omitempty"`
URL string `json:"url,omitempty"`
UID string `json:"uid,omitempty"`
Author *Card `json:"author,omitempty"`
Category []string `json:"category,omitempty"`
Photo []string `json:"photo,omitempty"`
LikeOf []string `json:"like-of,omitempty"`
BookmarkOf []string `json:"bookmark-of,omitempty"`
RepostOf []string `json:"repost-of,omitempty"`
InReplyTo []string `json:"in-reply-to,omitempty"`
Summary []string `json:"summary,omitempty"`
Content *Content `json:"content,omitempty"`
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"`
}
// Pagination contains information about paging