Ensure Updated field will be omitted when nil or zero

This commit is contained in:
Matt Baer
2023-10-02 21:30:47 -04:00
parent adbbafe3ee
commit d81124d454
+5 -3
View File
@@ -19,7 +19,7 @@ type Activity struct {
BaseObject
Actor string `json:"actor"`
Published time.Time `json:"published,omitempty"`
Updated time.Time `json:"updated,omitempty"`
Updated *time.Time `json:"updated,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
Object *Object `json:"object"`
@@ -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
}
@@ -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"`