From 50824cd75aa2e84779b524c782834599e3e7c2ca Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 3 Aug 2018 00:21:06 +0200 Subject: [PATCH] Fix parsing @context property Previously this would fail if the @context property also contained something other than a string, like Mastodon does. --- activitystreams/activity.go | 2 +- activitystreams/data.go | 10 +++++----- activitystreams/person.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/activitystreams/activity.go b/activitystreams/activity.go index 4eafa80..b1a5340 100644 --- a/activitystreams/activity.go +++ b/activitystreams/activity.go @@ -20,7 +20,7 @@ type Activity struct { func NewCreateActivity(o *Object) *Activity { a := Activity{ BaseObject: BaseObject{ - Context: []string{ + Context: []interface{}{ "https://www.w3.org/ns/activitystreams", }, ID: o.ID + "/activity", diff --git a/activitystreams/data.go b/activitystreams/data.go index 7c26588..d01d486 100644 --- a/activitystreams/data.go +++ b/activitystreams/data.go @@ -4,9 +4,9 @@ import "fmt" type ( BaseObject struct { - Context []string `json:"@context,omitempty"` - Type string `json:"type"` - ID string `json:"id"` + Context []interface{} `json:"@context,omitempty"` + Type string `json:"type"` + ID string `json:"id"` } PublicKey struct { @@ -33,7 +33,7 @@ type OrderedCollection struct { func NewOrderedCollection(accountRoot, collType string, items int) *OrderedCollection { oc := OrderedCollection{ BaseObject: BaseObject{ - Context: []string{ + Context: []interface{}{ "https://www.w3.org/ns/activitystreams", }, ID: accountRoot + "/" + collType, @@ -57,7 +57,7 @@ type OrderedCollectionPage struct { func NewOrderedCollectionPage(accountRoot, collType string, items, page int) *OrderedCollectionPage { ocp := OrderedCollectionPage{ BaseObject: BaseObject{ - Context: []string{ + Context: []interface{}{ "https://www.w3.org/ns/activitystreams", }, ID: fmt.Sprintf("%s/%s?page=%d", accountRoot, collType, page), diff --git a/activitystreams/person.go b/activitystreams/person.go index 57daa0f..3b43279 100644 --- a/activitystreams/person.go +++ b/activitystreams/person.go @@ -18,7 +18,7 @@ func NewPerson(accountRoot string) *Person { p := Person{ BaseObject: BaseObject{ Type: "Person", - Context: []string{ + Context: []interface{}{ "https://www.w3.org/ns/activitystreams", }, ID: accountRoot,