mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-06 02:33:22 -06:00
ensure that status.updated_at always fits chronologically
This commit is contained in:
parent
8edb57a782
commit
bcfa9af8a5
2 changed files with 13 additions and 5 deletions
|
|
@ -926,6 +926,15 @@ func (d *Dereferencer) updateStatus(
|
||||||
// any other changes in status content itself.
|
// any other changes in status content itself.
|
||||||
if pollChanged || statusChanged(existing, status) {
|
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
|
// Status has been editted since last
|
||||||
// we saw it, take snapshot of existing.
|
// we saw it, take snapshot of existing.
|
||||||
var edit gtsmodel.StatusEdit
|
var edit gtsmodel.StatusEdit
|
||||||
|
|
@ -1009,7 +1018,7 @@ func (d *Dereferencer) updateStatusPoll(
|
||||||
// insert latest poll version into database.
|
// insert latest poll version into database.
|
||||||
return true, d.insertStatusPoll(ctx, status)
|
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!
|
// Since we last saw it, the poll has updated!
|
||||||
// Whether that be stats, or close time.
|
// Whether that be stats, or close time.
|
||||||
poll := existing.Poll
|
poll := existing.Poll
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ func pollChanged(existing, latest *gtsmodel.Poll) bool {
|
||||||
!existing.ExpiresAt.Equal(latest.ExpiresAt)
|
!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.
|
// 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 ||
|
return *existing.Voters != *latest.Voters ||
|
||||||
!slices.Equal(existing.Votes, latest.Votes) ||
|
!slices.Equal(existing.Votes, latest.Votes) ||
|
||||||
!existing.ClosedAt.Equal(latest.ClosedAt)
|
!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
|
// statusChanged returns whether a status has changed in a way that
|
||||||
// indicates that existing should be snapshotted for version history.
|
// indicates that existing should be snapshotted for version history.
|
||||||
func statusChanged(existing, latest *gtsmodel.Status) bool {
|
func statusChanged(existing, latest *gtsmodel.Status) bool {
|
||||||
return !existing.UpdatedAt.Equal(latest.UpdatedAt) ||
|
return existing.Content != latest.Content ||
|
||||||
existing.Content != latest.Content ||
|
|
||||||
existing.ContentWarning != latest.ContentWarning ||
|
existing.ContentWarning != latest.ContentWarning ||
|
||||||
!slices.Equal(existing.AttachmentIDs, latest.AttachmentIDs)
|
!slices.Equal(existing.AttachmentIDs, latest.AttachmentIDs)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue