From c013892ca22fe6bface8dc580571b2f0527cd1db Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Wed, 8 Jan 2025 10:29:23 +0000 Subject: [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() --- internal/typeutils/internaltofrontend.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'internal/typeutils/internaltofrontend.go') diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 9fb69b438..a90e88a70 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -997,7 +997,7 @@ func (c *Converter) statusToAPIFilterResults( // Key this status based on ID + last updated time, // to ensure we always filter on latest version. - statusKey := s.ID + strconv.FormatInt(s.UpdatedAt.Unix(), 10) + statusKey := s.ID + strconv.FormatInt(s.UpdatedAt().Unix(), 10) // Check if we have filterable fields cached for this status. cache := c.state.Caches.StatusesFilterableFields @@ -1384,10 +1384,8 @@ func (c *Converter) baseStatusToFrontend( InteractionPolicy: *apiInteractionPolicy, } - // Only set edited_at if this is a non-boost-wrapper - // with an updated_at date different to creation date. - if !s.UpdatedAt.Equal(s.CreatedAt) && s.BoostOfID == "" { - timestamp := util.FormatISO8601(s.UpdatedAt) + if at := s.EditedAt; !at.IsZero() { + timestamp := util.FormatISO8601(at) apiStatus.EditedAt = util.Ptr(timestamp) } @@ -1522,8 +1520,8 @@ func (c *Converter) StatusToAPIEdits(ctx context.Context, status *gtsmodel.Statu PollOptions: options, PollVotes: votes, AttachmentIDs: status.AttachmentIDs, - AttachmentDescriptions: nil, // no change from current - CreatedAt: status.UpdatedAt, + AttachmentDescriptions: nil, // no change from current + CreatedAt: status.UpdatedAt(), // falls back to creation }) // Iterate through status edits, starting at newest. -- cgit v1.2.3