diff options
author | 2025-01-08 10:29:23 +0000 | |
---|---|---|
committer | 2025-01-08 11:29:23 +0100 | |
commit | c013892ca22fe6bface8dc580571b2f0527cd1db (patch) | |
tree | 8eccf44e188b2d906aa0bafc9fb37640f1526844 /internal/gtsmodel/status.go | |
parent | [feature] Create/update/remove domain permission subscriptions (#3623) (diff) | |
download | gotosocial-c013892ca22fe6bface8dc580571b2f0527cd1db.tar.xz |
[chore] replace statuses.updated_at column with statuses.edited_at (#3636)
* update statuses table to replace updated_at column with edited_at
* code comment
* better code comments, fix setting of status + edit + mention + poll database times
* fix log to logf call
* fix status.EditIDs not being carried over in dereferencer.encrichStatus()
* move status.EditID setting into handleStatusEdit()
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"` |