diff options
Diffstat (limited to 'internal/gtsmodel/status.go')
-rw-r--r-- | internal/gtsmodel/status.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go index 3a348bba4..d28898ed1 100644 --- a/internal/gtsmodel/status.go +++ b/internal/gtsmodel/status.go @@ -28,7 +28,7 @@ import ( type Status struct { ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created - UpdatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item last updated + EditedAt time.Time `bun:"type:timestamptz,nullzero"` // when this status was last edited (if set) FetchedAt time.Time `bun:"type:timestamptz,nullzero"` // when was item (remote) last fetched. PinnedAt time.Time `bun:"type:timestamptz,nullzero"` // Status was pinned by owning account at this time. URI string `bun:",unique,nullzero,notnull"` // activitypub URI of this status @@ -299,6 +299,15 @@ func (s *Status) AllAttachmentIDs() []string { return xslices.Deduplicate(attachmentIDs) } +// UpdatedAt returns latest time this status +// was updated, either EditedAt or CreatedAt. +func (s *Status) UpdatedAt() time.Time { + if s.EditedAt.IsZero() { + return s.CreatedAt + } + return s.EditedAt +} + // StatusToTag is an intermediate struct to facilitate the many2many relationship between a status and one or more tags. type StatusToTag struct { StatusID string `bun:"type:CHAR(26),unique:statustag,nullzero,notnull"` |