Changes
5 changed files (+45/-68)
-
-
@@ -1507,10 +1507,6 @@ func (a *Activity) UnmarshalJSON(data []byte) error {a.Parent.UnmarshalJSON(data) a.Actor = getAPItem(data, "actor") a.Object = getAPItem(data, "object") to := getAPItemCollection(data, "to") if to != nil { a.To = to } return nil }
-
-
-
@@ -540,19 +540,19 @@ func (o *Object) UnmarshalJSON(data []byte) error {o.Published = getAPTime(data, "published") o.StartTime = getAPTime(data, "startTime") o.Updated = getAPTime(data, "updated") to := getAPItemCollection(data, "to") to := getAPItems(data, "to") if to != nil { o.To = to } bto := getAPItemCollection(data, "bto") bto := getAPItems(data, "bto") if bto != nil { o.Bto = bto } cc := getAPItemCollection(data, "cc") cc := getAPItems(data, "cc") if cc != nil { o.CC = cc } bcc := getAPItemCollection(data, "bcc") bcc := getAPItems(data, "bcc") if bcc != nil { o.BCC = bcc }
-
@@ -560,7 +560,7 @@ func (o *Object) UnmarshalJSON(data []byte) error {if replies != nil { o.Replies = replies } tag := getAPItemCollection(data, "tag") tag := getAPItems(data, "tag") if tag != nil { o.Tag = tag }
-
-
-
@@ -161,31 +161,7 @@ func getAPItems(data []byte, prop string) ItemCollection {switch typ { case jsonparser.Array: jsonparser.ArrayEach(data, func(value []byte, dataType jsonparser.ValueType, offset int, err error) { var i Item switch dataType { case jsonparser.String: if _, err = url.ParseRequestURI(string(val)); err == nil { // try to see if it's an IRI i = IRI(value) } case jsonparser.Object: i = unmarshalToAPObject(value) case jsonparser.Number: fallthrough case jsonparser.Array: fallthrough case jsonparser.Boolean: fallthrough case jsonparser.Null: fallthrough case jsonparser.Unknown: fallthrough default: return } if err != nil { return } i := unmarshalToAPObject(value) if i != nil { it.Append(i) }
-
@@ -205,40 +181,6 @@ func getAPItems(data []byte, prop string) ItemCollection {return it } func getAPItemCollection(data []byte, prop string) ItemCollection { val, typ, _, err := jsonparser.Get(data, prop) if err != nil { return nil } var it ItemCollection switch typ { case jsonparser.Array: jsonparser.ArrayEach(data, func(value []byte, dataType jsonparser.ValueType, offset int, err error) { i, err := getAPObjectByType(getAPType(value)) if err != nil { return } err = i.(json.Unmarshaler).UnmarshalJSON(value) if err != nil { return } it.Append(i) }, prop) case jsonparser.Object: jsonparser.ObjectEach(data, func(key []byte, value []byte, dataType jsonparser.ValueType, offset int) error { i := Object{} err := i.UnmarshalJSON(val) it.Append(i) return err }, prop) case jsonparser.String: it.Append(IRI(val)) } return it } func getURIField(data []byte, prop string) Item { val, typ, _, err := jsonparser.Get(data, prop) if err != nil {
-
-
-
@@ -0,0 +1,18 @@{ "@context": "https://www.w3.org/ns/activitystreams", "type": "Object", "id": "http://www.test.example/object/1", "to": [ "https://www.w3.org/ns/activitystreams#Public" ], "bto": [ "http://example.com/sharedInbox" ], "cc": [ "https://example.com/actors/ana", "https://example.com/actors/bob" ], "bcc": [ "https://darkside.cookie/actors/darthvader" ] }
-
-
-
@@ -431,6 +431,27 @@ var allTests = tests{Published: time.Date(2018, time.September, 6, 15, 15, 9, 0, zLoc), }, }, "object_with_audience": testPair{ expected: true, blank: &a.Object{}, result: &a.Object{ Type: a.ObjectType, ID: a.ObjectID("http://www.test.example/object/1"), To: a.ItemCollection{ a.IRI("https://www.w3.org/ns/activitystreams#Public"), }, Bto: a.ItemCollection{ a.IRI("http://example.com/sharedInbox"), }, CC: a.ItemCollection{ a.IRI("https://example.com/actors/ana"), a.IRI("https://example.com/actors/bob"), }, BCC: a.ItemCollection{ a.IRI( "https://darkside.cookie/actors/darthvader"), }, }, }, } func getFileContents(path string) ([]byte, error) {
-