Skip to content

Commit

Permalink
Ensure Updated field will be omitted when nil or zero
Browse files Browse the repository at this point in the history
  • Loading branch information
thebaer committed Oct 3, 2023
1 parent adbbafe commit d81124d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions activitystreams/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ var Extensions = map[string]string{}
// process of occurring, or may occur in the future.
type Activity struct {
BaseObject
Actor string `json:"actor"`
Published time.Time `json:"published,omitempty"`
Updated time.Time `json:"updated,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
Object *Object `json:"object"`
Actor string `json:"actor"`
Published time.Time `json:"published,omitempty"`
Updated *time.Time `json:"updated,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
Object *Object `json:"object"`
}

type FollowActivity struct {
Expand Down Expand Up @@ -68,7 +68,9 @@ func NewUpdateActivity(o *Object) *Activity {
Actor: o.AttributedTo,
Object: o,
Published: o.Published,
Updated: o.Updated,
}
if o.Updated != nil && !o.Updated.IsZero() {
a.Updated = o.Updated
}
return &a
}
Expand Down Expand Up @@ -109,7 +111,7 @@ func NewFollowActivity(actorIRI, followeeIRI string) *FollowActivity {
type Object struct {
BaseObject
Published time.Time `json:"published,omitempty"`
Updated time.Time `json:"updated,omitempty"`
Updated *time.Time `json:"updated,omitempty"`
Summary *string `json:"summary,omitempty"`
InReplyTo *string `json:"inReplyTo,omitempty"`
URL string `json:"url"`
Expand Down

0 comments on commit d81124d

Please sign in to comment.