From d67ec28bcc40e627a91eb27214ddb5190ce8999d Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 25 Jun 2018 13:35:47 -0400 Subject: [PATCH] Leave out certain properties in Activity JSON --- activitystreams/activity.go | 19 ++++++++----------- activitystreams/data.go | 2 +- activitystreams/person.go | 1 - 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/activitystreams/activity.go b/activitystreams/activity.go index 95f2bf1..aae78f0 100644 --- a/activitystreams/activity.go +++ b/activitystreams/activity.go @@ -11,9 +11,9 @@ const ( type Activity struct { BaseObject Actor string `json:"actor"` - Published time.Time `json:"published"` - To []string `json:"to"` - CC []string `json:"cc"` + Published time.Time `json:"published,omitempty"` + To []string `json:"to,omitempty"` + CC []string `json:"cc,omitempty"` Object *Object `json:"object"` } @@ -23,11 +23,8 @@ func NewCreateActivity(o *Object) *Activity { ID: o.ID + "/activity", Type: "Create", }, - Actor: o.AttributedTo, - Published: o.Published, - To: o.To, - CC: o.CC, - Object: o, + Actor: o.AttributedTo, + Object: o, } return &a } @@ -35,14 +32,14 @@ func NewCreateActivity(o *Object) *Activity { type Object struct { BaseObject Published time.Time `json:"published"` - Summary *string `json:"summary"` + Summary *string `json:"summary,omitempty"` InReplyTo *string `json:"inReplyTo"` URL string `json:"url"` AttributedTo string `json:"attributedTo"` To []string `json:"to"` - CC []string `json:"cc"` + CC []string `json:"cc,omitempty"` Content string `json:"content"` - ContentMap map[string]string `json:"contentMap"` + ContentMap map[string]string `json:"contentMap,omitempty"` } func NewNoteObject() *Object { diff --git a/activitystreams/data.go b/activitystreams/data.go index 42f3bfc..e96528a 100644 --- a/activitystreams/data.go +++ b/activitystreams/data.go @@ -4,7 +4,7 @@ import "fmt" type ( BaseObject struct { - Context []string `json:"@context"` + Context []string `json:"@context,omitempty"` Type string `json:"type"` ID string `json:"id"` } diff --git a/activitystreams/person.go b/activitystreams/person.go index 3fc4e41..57daa0f 100644 --- a/activitystreams/person.go +++ b/activitystreams/person.go @@ -23,7 +23,6 @@ func NewPerson(accountRoot string) *Person { }, ID: accountRoot, }, - URL: accountRoot, Following: accountRoot + "/following", Followers: accountRoot + "/followers", Inbox: accountRoot + "/inbox",