Changes
11 changed files (+147/-667)
-
-
@@ -316,74 +316,7 @@ func (a *Actor) Clean() {} func (a *Actor) UnmarshalJSON(data []byte) error { if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } a.ID = JSONGetID(data) a.Type = JSONGetType(data) a.Name = JSONGetNaturalLanguageField(data, "name") a.Content = JSONGetNaturalLanguageField(data, "content") a.Summary = JSONGetNaturalLanguageField(data, "summary") a.Context = JSONGetItem(data, "context") a.URL = JSONGetURIItem(data, "url") a.MediaType = MimeType(JSONGetString(data, "mediaType")) a.Generator = JSONGetItem(data, "generator") a.AttributedTo = JSONGetItem(data, "attributedTo") a.Attachment = JSONGetItem(data, "attachment") a.Location = JSONGetItem(data, "location") a.Published = JSONGetTime(data, "published") a.StartTime = JSONGetTime(data, "startTime") a.EndTime = JSONGetTime(data, "endTime") a.Duration = JSONGetDuration(data, "duration") a.Icon = JSONGetItem(data, "icon") a.Preview = JSONGetItem(data, "preview") a.Image = JSONGetItem(data, "image") a.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { a.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { a.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { a.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { a.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { a.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { a.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { a.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { a.Tag = tag } a.Likes = JSONGetItem(data, "likes") a.Shares = JSONGetItem(data, "shares") a.Source = GetAPSource(data) a.PreferredUsername = JSONGetNaturalLanguageField(data, "preferredUsername") a.Followers = JSONGetItem(data, "followers") a.Following = JSONGetItem(data, "following") a.Inbox = JSONGetItem(data, "inbox") a.Outbox = JSONGetItem(data, "outbox") a.Liked = JSONGetItem(data, "liked") a.Endpoints = JSONGetActorEndpoints(data, "endpoints") a.Streams = JSONGetStreams(data, "streams") a.PublicKey = JSONGetPublicKey(data, "publicKey") return nil return loadActor(data, a) } func (a Actor) MarshalJSON() ([]byte, error) {
-
-
-
@@ -229,70 +229,7 @@ func (c Collection) Contains(r IRI) bool {// UnmarshalJSON func (c *Collection) UnmarshalJSON(data []byte) error { if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } c.ID = JSONGetID(data) c.Type = JSONGetType(data) c.Name = JSONGetNaturalLanguageField(data, "name") c.Content = JSONGetNaturalLanguageField(data, "content") c.Summary = JSONGetNaturalLanguageField(data, "summary") c.Context = JSONGetItem(data, "context") c.URL = JSONGetURIItem(data, "url") c.MediaType = MimeType(JSONGetString(data, "mediaType")) c.Generator = JSONGetItem(data, "generator") c.AttributedTo = JSONGetItem(data, "attributedTo") c.Attachment = JSONGetItem(data, "attachment") c.Location = JSONGetItem(data, "location") c.Published = JSONGetTime(data, "published") c.StartTime = JSONGetTime(data, "startTime") c.EndTime = JSONGetTime(data, "endTime") c.Duration = JSONGetDuration(data, "duration") c.Icon = JSONGetItem(data, "icon") c.Preview = JSONGetItem(data, "preview") c.Image = JSONGetItem(data, "image") c.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { c.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { c.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { c.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { c.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { c.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { c.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { c.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { c.Tag = tag } c.TotalItems = uint(JSONGetInt(data, "totalItems")) c.Items = JSONGetItems(data, "items") c.Current = JSONGetItem(data, "current") c.First = JSONGetItem(data, "first") c.Last = JSONGetItem(data, "last") return nil return loadCollection(data, c) } // MarshalJSON
-
-
-
@@ -184,74 +184,7 @@ func (c CollectionPage) Contains(r IRI) bool {// UnmarshalJSON func (c *CollectionPage) UnmarshalJSON(data []byte) error { if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } c.ID = JSONGetID(data) c.Type = JSONGetType(data) c.Name = JSONGetNaturalLanguageField(data, "name") c.Content = JSONGetNaturalLanguageField(data, "content") c.Summary = JSONGetNaturalLanguageField(data, "summary") c.Context = JSONGetItem(data, "context") c.URL = JSONGetURIItem(data, "url") c.MediaType = MimeType(JSONGetString(data, "mediaType")) c.Generator = JSONGetItem(data, "generator") c.AttributedTo = JSONGetItem(data, "attributedTo") c.Attachment = JSONGetItem(data, "attachment") c.Location = JSONGetItem(data, "location") c.Published = JSONGetTime(data, "published") c.StartTime = JSONGetTime(data, "startTime") c.EndTime = JSONGetTime(data, "endTime") c.Duration = JSONGetDuration(data, "duration") c.Icon = JSONGetItem(data, "icon") c.Preview = JSONGetItem(data, "preview") c.Image = JSONGetItem(data, "image") c.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { c.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { c.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { c.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { c.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { c.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { c.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { c.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { c.Tag = tag } c.TotalItems = uint(JSONGetInt(data, "totalItems")) c.Items = JSONGetItems(data, "items") c.Current = JSONGetItem(data, "current") c.First = JSONGetItem(data, "first") c.Last = JSONGetItem(data, "last") c.Next = JSONGetItem(data, "next") c.Prev = JSONGetItem(data, "prev") c.PartOf = JSONGetItem(data, "partOf") return nil return loadCollectionPage(data, c) } // MarshalJSON
-
-
-
@@ -341,7 +341,7 @@ func JSONGetItemByType(typ ActivityVocabularyType) (Item, error) {case IntransitiveActivityType: return &IntransitiveActivity{Type: typ}, nil case ActorType: return &Actor{Type:typ}, nil return &Actor{Type: typ}, nil case CollectionType: return &Collection{Type: typ}, nil case OrderedCollectionType:
-
@@ -377,15 +377,15 @@ func JSONGetItemByType(typ ActivityVocabularyType) (Item, error) {case MentionType: return &Mention{Type: typ}, nil case ApplicationType: return &Application{Type:typ}, nil return &Application{Type: typ}, nil case GroupType: return &Group{Type:typ}, nil return &Group{Type: typ}, nil case OrganizationType: return &Organization{Type:typ}, nil return &Organization{Type: typ}, nil case PersonType: return &Person{Type:typ}, nil return &Person{Type: typ}, nil case ServiceType: return &Service{Type:typ}, nil return &Service{Type: typ}, nil case AcceptType: return &Accept{Type: typ}, nil case AddType:
-
@@ -542,3 +542,116 @@ func loadActivity(data []byte, a *Activity) error {a.Object = JSONGetItem(data, "object") return nil } func loadQuestion(data []byte, q *Question) error { OnIntransitiveActivity(q, func(i *IntransitiveActivity) error { return loadIntrasitiveActivity(data, i) }) q.OneOf = JSONGetItem(data, "oneOf") q.AnyOf = JSONGetItem(data, "anyOf") q.Closed = JSONGetBoolean(data, "closed") return nil } func loadActor(data []byte, a *Actor) error { OnObject(a, func(o *Object) error { return loadObject(data, o) }) a.PreferredUsername = JSONGetNaturalLanguageField(data, "preferredUsername") a.Followers = JSONGetItem(data, "followers") a.Following = JSONGetItem(data, "following") a.Inbox = JSONGetItem(data, "inbox") a.Outbox = JSONGetItem(data, "outbox") a.Liked = JSONGetItem(data, "liked") a.Endpoints = JSONGetActorEndpoints(data, "endpoints") a.Streams = JSONGetStreams(data, "streams") a.PublicKey = JSONGetPublicKey(data, "publicKey") return nil } func loadCollection(data []byte, c *Collection) error { OnObject(c, func(o *Object) error { return loadObject(data, o) }) c.Items = JSONGetItems(data, "items") c.TotalItems = uint(JSONGetInt(data, "totalItems")) c.Current = JSONGetItem(data, "current") c.First = JSONGetItem(data, "first") c.Last = JSONGetItem(data, "last") return nil } func loadCollectionPage(data []byte, c *CollectionPage) error { OnCollection(c, func(c CollectionInterface) error { return loadCollection(data, c.(*Collection)) }) c.Next = JSONGetItem(data, "next") c.Prev = JSONGetItem(data, "prev") c.PartOf = JSONGetItem(data, "partOf") return nil } func loadOrderedCollection(data []byte, c *OrderedCollection) error { OnObject(c, func(o *Object) error { return loadObject(data, o) }) c.OrderedItems = JSONGetItems(data, "orderedItems") c.TotalItems = uint(JSONGetInt(data, "totalItems")) c.Current = JSONGetItem(data, "current") c.First = JSONGetItem(data, "first") c.Last = JSONGetItem(data, "last") return nil } func loadOrderedCollectionPage(data []byte, c *OrderedCollectionPage) error { OnOrderedCollection(c, func(c *OrderedCollection) error { return loadOrderedCollection(data, c) }) c.Next = JSONGetItem(data, "next") c.Prev = JSONGetItem(data, "prev") c.PartOf = JSONGetItem(data, "partOf") if si, err := jsonparser.GetInt(data, "startIndex"); err != nil { c.StartIndex = uint(si) } return nil } func loadPlace(data []byte, p *Place) error { OnObject(p, func(o *Object) error { return loadObject(data, o) }) p.Accuracy = JSONGetFloat(data, "accuracy") p.Altitude = JSONGetFloat(data, "altitude") p.Latitude = JSONGetFloat(data, "latitude") p.Longitude = JSONGetFloat(data, "longitude") p.Radius = JSONGetInt(data, "radius") p.Units = JSONGetString(data, "units") return nil } func loadProfile(data []byte, p *Profile) error { OnObject(p, func(o *Object) error { return loadObject(data, o) }) p.Describes = JSONGetItem(data, "describes") return nil } func loadRelationship(data []byte, r *Relationship) error { OnObject(r, func(o *Object) error { return loadObject(data, o) }) r.Subject = JSONGetItem(data, "subject") r.Object = JSONGetItem(data, "object") r.Relationship = JSONGetItem(data, "relationship") return nil } func loadTombstone(data []byte, t *Tombstone) error { OnObject(t, func(o *Object) error { return loadObject(data, o) }) t.FormerType = ActivityVocabularyType(JSONGetString(data, "formerType")) t.Deleted = JSONGetTime(data, "deleted") return nil }
-
-
-
@@ -225,70 +225,7 @@ func (o *OrderedCollection) Append(ob Item) error {// UnmarshalJSON func (o *OrderedCollection) UnmarshalJSON(data []byte) error { if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } o.ID = JSONGetID(data) o.Type = JSONGetType(data) o.Name = JSONGetNaturalLanguageField(data, "name") o.Content = JSONGetNaturalLanguageField(data, "content") o.Summary = JSONGetNaturalLanguageField(data, "summary") o.Context = JSONGetItem(data, "context") o.URL = JSONGetURIItem(data, "url") o.MediaType = MimeType(JSONGetString(data, "mediaType")) o.Generator = JSONGetItem(data, "generator") o.AttributedTo = JSONGetItem(data, "attributedTo") o.Attachment = JSONGetItem(data, "attachment") o.Location = JSONGetItem(data, "location") o.Published = JSONGetTime(data, "published") o.StartTime = JSONGetTime(data, "startTime") o.EndTime = JSONGetTime(data, "endTime") o.Duration = JSONGetDuration(data, "duration") o.Icon = JSONGetItem(data, "icon") o.Preview = JSONGetItem(data, "preview") o.Image = JSONGetItem(data, "image") o.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { o.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { o.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { o.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { o.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { o.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { o.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { o.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { o.Tag = tag } o.TotalItems = uint(JSONGetInt(data, "totalItems")) o.OrderedItems = JSONGetItems(data, "orderedItems") o.Current = JSONGetItem(data, "current") o.First = JSONGetItem(data, "first") o.Last = JSONGetItem(data, "last") return nil return loadOrderedCollection(data, o) } // MarshalJSON
-
-
-
@@ -2,7 +2,6 @@ package activitypubimport ( "errors" "github.com/buger/jsonparser" "time" )
-
@@ -188,110 +187,41 @@ func (o OrderedCollectionPage) Contains(r IRI) bool {// UnmarshalJSON func (o *OrderedCollectionPage) UnmarshalJSON(data []byte) error { if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } o.ID = JSONGetID(data) o.Type = JSONGetType(data) o.Name = JSONGetNaturalLanguageField(data, "name") o.Content = JSONGetNaturalLanguageField(data, "content") o.Summary = JSONGetNaturalLanguageField(data, "summary") o.Context = JSONGetItem(data, "context") o.URL = JSONGetURIItem(data, "url") o.MediaType = MimeType(JSONGetString(data, "mediaType")) o.Generator = JSONGetItem(data, "generator") o.AttributedTo = JSONGetItem(data, "attributedTo") o.Attachment = JSONGetItem(data, "attachment") o.Location = JSONGetItem(data, "location") o.Published = JSONGetTime(data, "published") o.StartTime = JSONGetTime(data, "startTime") o.EndTime = JSONGetTime(data, "endTime") o.Duration = JSONGetDuration(data, "duration") o.Icon = JSONGetItem(data, "icon") o.Preview = JSONGetItem(data, "preview") o.Image = JSONGetItem(data, "image") o.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { o.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { o.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { o.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { o.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { o.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { o.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { o.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { o.Tag = tag } o.TotalItems = uint(JSONGetInt(data, "totalItems")) o.OrderedItems = JSONGetItems(data, "orderedItems") o.Current = JSONGetItem(data, "current") o.First = JSONGetItem(data, "first") o.Last = JSONGetItem(data, "last") o.Next = JSONGetItem(data, "next") o.Prev = JSONGetItem(data, "prev") o.PartOf = JSONGetItem(data, "partOf") if si, err := jsonparser.GetInt(data, "startIndex"); err != nil { o.StartIndex = uint(si) } return nil return loadOrderedCollectionPage(data, o) } // MarshalJSON func (c OrderedCollectionPage) MarshalJSON() ([]byte, error) { func (o OrderedCollectionPage) MarshalJSON() ([]byte, error) { b := make([]byte, 0) notEmpty := false write(&b, '{') OnObject(c, func(o *Object) error { OnObject(o, func(o *Object) error { notEmpty = writeObjectValue(&b, *o) return nil }) if c.Current != nil { notEmpty = writeItemProp(&b, "current", c.Current) || notEmpty if o.Current != nil { notEmpty = writeItemProp(&b, "current", o.Current) || notEmpty } if c.First != nil { notEmpty = writeItemProp(&b, "first", c.First) || notEmpty if o.First != nil { notEmpty = writeItemProp(&b, "first", o.First) || notEmpty } if c.Last != nil { notEmpty = writeItemProp(&b, "last", c.Last) || notEmpty if o.Last != nil { notEmpty = writeItemProp(&b, "last", o.Last) || notEmpty } if c.OrderedItems != nil { notEmpty = writeItemCollectionProp(&b, "orderedItems", c.OrderedItems) || notEmpty if o.OrderedItems != nil { notEmpty = writeItemCollectionProp(&b, "orderedItems", o.OrderedItems) || notEmpty } if c.PartOf != nil { notEmpty = writeItemProp(&b, "partOf", c.PartOf) || notEmpty if o.PartOf != nil { notEmpty = writeItemProp(&b, "partOf", o.PartOf) || notEmpty } if c.Next != nil { notEmpty = writeItemProp(&b, "next", c.Next) || notEmpty if o.Next != nil { notEmpty = writeItemProp(&b, "next", o.Next) || notEmpty } if c.Prev != nil { notEmpty = writeItemProp(&b, "prev", c.Prev) || notEmpty if o.Prev != nil { notEmpty = writeItemProp(&b, "prev", o.Prev) || notEmpty } notEmpty = writeIntProp(&b, "totalItems", int64(c.TotalItems)) || notEmpty notEmpty = writeIntProp(&b, "totalItems", int64(o.TotalItems)) || notEmpty if notEmpty { write(&b, '}')
-
-
-
@@ -152,70 +152,7 @@ func (p Place) GetID() ID {// UnmarshalJSON func (p *Place) UnmarshalJSON(data []byte) error { // TODO(marius): this is a candidate of using OnObject() for loading the common properties // and then loading the extra ones if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } p.ID = JSONGetID(data) p.Type = JSONGetType(data) p.Name = JSONGetNaturalLanguageField(data, "name") p.Content = JSONGetNaturalLanguageField(data, "content") p.Summary = JSONGetNaturalLanguageField(data, "summary") p.Context = JSONGetItem(data, "context") p.URL = JSONGetURIItem(data, "url") p.MediaType = MimeType(JSONGetString(data, "mediaType")) p.Generator = JSONGetItem(data, "generator") p.AttributedTo = JSONGetItem(data, "attributedTo") p.Attachment = JSONGetItem(data, "attachment") p.Location = JSONGetItem(data, "location") p.Published = JSONGetTime(data, "published") p.StartTime = JSONGetTime(data, "startTime") p.EndTime = JSONGetTime(data, "endTime") p.Duration = JSONGetDuration(data, "duration") p.Icon = JSONGetItem(data, "icon") p.Preview = JSONGetItem(data, "preview") p.Image = JSONGetItem(data, "image") p.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { p.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { p.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { p.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { p.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { p.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { p.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { p.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { p.Tag = tag } p.Accuracy = JSONGetFloat(data, "accuracy") p.Altitude = JSONGetFloat(data, "altitude") p.Latitude = JSONGetFloat(data, "latitude") p.Longitude = JSONGetFloat(data, "longitude") p.Radius = JSONGetInt(data, "radius") p.Units = JSONGetString(data, "units") return nil return loadPlace(data, p) } // MarshalJSON
-
-
-
@@ -138,65 +138,7 @@ func (p Profile) GetID() ID {// UnmarshalJSON func (p *Profile) UnmarshalJSON(data []byte) error { // TODO(marius): this is a candidate of using OnObject() for loading the common properties // and then loading the extra ones if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } p.ID = JSONGetID(data) p.Type = JSONGetType(data) p.Name = JSONGetNaturalLanguageField(data, "name") p.Content = JSONGetNaturalLanguageField(data, "content") p.Summary = JSONGetNaturalLanguageField(data, "summary") p.Context = JSONGetItem(data, "context") p.URL = JSONGetURIItem(data, "url") p.MediaType = MimeType(JSONGetString(data, "mediaType")) p.Generator = JSONGetItem(data, "generator") p.AttributedTo = JSONGetItem(data, "attributedTo") p.Attachment = JSONGetItem(data, "attachment") p.Location = JSONGetItem(data, "location") p.Published = JSONGetTime(data, "published") p.StartTime = JSONGetTime(data, "startTime") p.EndTime = JSONGetTime(data, "endTime") p.Duration = JSONGetDuration(data, "duration") p.Icon = JSONGetItem(data, "icon") p.Preview = JSONGetItem(data, "preview") p.Image = JSONGetItem(data, "image") p.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { p.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { p.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { p.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { p.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { p.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { p.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { p.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { p.Tag = tag } p.Describes = JSONGetItem(data, "describes") return nil return loadProfile(data, p) } // MarshalJSON
-
-
-
@@ -163,70 +163,7 @@ func (q Question) IsCollection() bool {// UnmarshalJSON func (q *Question) UnmarshalJSON(data []byte) error { if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } q.ID = JSONGetID(data) q.Type = JSONGetType(data) q.Name = JSONGetNaturalLanguageField(data, "name") q.Content = JSONGetNaturalLanguageField(data, "content") q.Summary = JSONGetNaturalLanguageField(data, "summary") q.Context = JSONGetItem(data, "context") q.URL = JSONGetURIItem(data, "url") q.MediaType = MimeType(JSONGetString(data, "mediaType")) q.Generator = JSONGetItem(data, "generator") q.AttributedTo = JSONGetItem(data, "attributedTo") q.Attachment = JSONGetItem(data, "attachment") q.Location = JSONGetItem(data, "location") q.Published = JSONGetTime(data, "published") q.StartTime = JSONGetTime(data, "startTime") q.EndTime = JSONGetTime(data, "endTime") q.Duration = JSONGetDuration(data, "duration") q.Icon = JSONGetItem(data, "icon") q.Preview = JSONGetItem(data, "preview") q.Image = JSONGetItem(data, "image") q.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { q.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { q.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { q.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { q.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { q.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { q.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { q.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { q.Tag = tag } q.Actor = JSONGetItem(data, "actor") q.Target = JSONGetItem(data, "target") q.Origin = JSONGetItem(data, "origin") q.Result = JSONGetItem(data, "result") q.Instrument = JSONGetItem(data, "instrument") q.OneOf = JSONGetItem(data, "oneOf") q.AnyOf = JSONGetItem(data, "anyOf") q.Closed = JSONGetBoolean(data, "closed") return nil return loadQuestion(data, q) } func (q Question) MarshalJSON() ([]byte, error) {
-
-
-
@@ -148,67 +148,7 @@ func (r Relationship) GetID() ID {// UnmarshalJSON func (r *Relationship) UnmarshalJSON(data []byte) error { // TODO(marius): this is a candidate of using OnObject() for loading the common properties // and then loading the extra ones if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } r.ID = JSONGetID(data) r.Type = JSONGetType(data) r.Name = JSONGetNaturalLanguageField(data, "name") r.Content = JSONGetNaturalLanguageField(data, "content") r.Summary = JSONGetNaturalLanguageField(data, "summary") r.Context = JSONGetItem(data, "context") r.URL = JSONGetURIItem(data, "url") r.MediaType = MimeType(JSONGetString(data, "mediaType")) r.Generator = JSONGetItem(data, "generator") r.AttributedTo = JSONGetItem(data, "attributedTo") r.Attachment = JSONGetItem(data, "attachment") r.Location = JSONGetItem(data, "location") r.Published = JSONGetTime(data, "published") r.StartTime = JSONGetTime(data, "startTime") r.EndTime = JSONGetTime(data, "endTime") r.Duration = JSONGetDuration(data, "duration") r.Icon = JSONGetItem(data, "icon") r.Preview = JSONGetItem(data, "preview") r.Image = JSONGetItem(data, "image") r.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { r.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { r.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { r.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { r.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { r.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { r.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { r.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { r.Tag = tag } r.Subject = JSONGetItem(data, "subject") r.Object = JSONGetItem(data, "object") r.Relationship = JSONGetItem(data, "relationship") return nil return loadRelationship(data, r) } // MarshalJSON
-
-
-
@@ -140,66 +140,7 @@ func (t Tombstone) GetID() ID {// UnmarshalJSON func (t *Tombstone) UnmarshalJSON(data []byte) error { // TODO(marius): this is a candidate of using OnObject() for loading the common properties // and then loading the extra ones if ItemTyperFunc == nil { ItemTyperFunc = JSONGetItemByType } t.ID = JSONGetID(data) t.Type = JSONGetType(data) t.Name = JSONGetNaturalLanguageField(data, "name") t.Content = JSONGetNaturalLanguageField(data, "content") t.Summary = JSONGetNaturalLanguageField(data, "summary") t.Context = JSONGetItem(data, "context") t.URL = JSONGetURIItem(data, "url") t.MediaType = MimeType(JSONGetString(data, "mediaType")) t.Generator = JSONGetItem(data, "generator") t.AttributedTo = JSONGetItem(data, "attributedTo") t.Attachment = JSONGetItem(data, "attachment") t.Location = JSONGetItem(data, "location") t.Published = JSONGetTime(data, "published") t.StartTime = JSONGetTime(data, "startTime") t.EndTime = JSONGetTime(data, "endTime") t.Duration = JSONGetDuration(data, "duration") t.Icon = JSONGetItem(data, "icon") t.Preview = JSONGetItem(data, "preview") t.Image = JSONGetItem(data, "image") t.Updated = JSONGetTime(data, "updated") inReplyTo := JSONGetItems(data, "inReplyTo") if len(inReplyTo) > 0 { t.InReplyTo = inReplyTo } to := JSONGetItems(data, "to") if len(to) > 0 { t.To = to } audience := JSONGetItems(data, "audience") if len(audience) > 0 { t.Audience = audience } bto := JSONGetItems(data, "bto") if len(bto) > 0 { t.Bto = bto } cc := JSONGetItems(data, "cc") if len(cc) > 0 { t.CC = cc } bcc := JSONGetItems(data, "bcc") if len(bcc) > 0 { t.BCC = bcc } replies := JSONGetItem(data, "replies") if replies != nil { t.Replies = replies } tag := JSONGetItems(data, "tag") if len(tag) > 0 { t.Tag = tag } t.FormerType = ActivityVocabularyType(JSONGetString(data, "formerType")) t.Deleted = JSONGetTime(data, "deleted") return nil return loadTombstone(data, t) } // MarshalJSON
-