diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go index 066a65dea..f8eeb81f1 100644 --- a/internal/federation/dereferencing/status.go +++ b/internal/federation/dereferencing/status.go @@ -926,6 +926,15 @@ func (d *Dereferencer) updateStatus( // any other changes in status content itself. if pollChanged || statusChanged(existing, status) { + // We prefer to use provided 'upated_at', but ensure + // it fits chronologically with creation / last update. + if !status.UpdatedAt.After(status.CreatedAt) || + !status.UpdatedAt.After(existing.UpdatedAt) { + + // Else fallback to now as update time. + status.UpdatedAt = status.FetchedAt + } + // Status has been editted since last // we saw it, take snapshot of existing. var edit gtsmodel.StatusEdit @@ -1009,7 +1018,7 @@ func (d *Dereferencer) updateStatusPoll( // insert latest poll version into database. return true, d.insertStatusPoll(ctx, status) - case pollUpdated(existing.Poll, status.Poll): + case pollStateUpdated(existing.Poll, status.Poll): // Since we last saw it, the poll has updated! // Whether that be stats, or close time. poll := existing.Poll diff --git a/internal/federation/dereferencing/util.go b/internal/federation/dereferencing/util.go index 4c337c981..40dfb2fde 100644 --- a/internal/federation/dereferencing/util.go +++ b/internal/federation/dereferencing/util.go @@ -58,9 +58,9 @@ func pollChanged(existing, latest *gtsmodel.Poll) bool { !existing.ExpiresAt.Equal(latest.ExpiresAt) } -// pollUpdated returns whether a poll has updated, i.e. if the +// pollStateUpdated returns whether a poll has updated, i.e. if // vote counts have changed, or if it has expired / been closed. -func pollUpdated(existing, latest *gtsmodel.Poll) bool { +func pollStateUpdated(existing, latest *gtsmodel.Poll) bool { return *existing.Voters != *latest.Voters || !slices.Equal(existing.Votes, latest.Votes) || !existing.ClosedAt.Equal(latest.ClosedAt) @@ -74,8 +74,7 @@ func pollJustClosed(existing, latest *gtsmodel.Poll) bool { // statusChanged returns whether a status has changed in a way that // indicates that existing should be snapshotted for version history. func statusChanged(existing, latest *gtsmodel.Status) bool { - return !existing.UpdatedAt.Equal(latest.UpdatedAt) || - existing.Content != latest.Content || + return existing.Content != latest.Content || existing.ContentWarning != latest.ContentWarning || !slices.Equal(existing.AttachmentIDs, latest.AttachmentIDs) }