improve handling of remote status updated_at to fix previous cases

This commit is contained in:
kim 2024-12-24 14:25:02 +00:00
commit 9e6625d309

View file

@ -1157,6 +1157,25 @@ func (d *Dereferencer) handleStatusEdit(
edited = true
}
switch {
// We prefer to use provided 'upated_at', but ensure
// it fits chronologically with creation / last update.
// updated_at has jumped backward, safety check it.
case existing.UpdatedAt.Before(status.UpdatedAt):
cols = append(cols, "updated_at")
if existing.CreatedAt.After(status.UpdatedAt) {
// It's jumped behind creation date,
// at least match it to creation time.
status.UpdatedAt = existing.CreatedAt
}
// updated_at has jumped forward, this is fine.
case existing.UpdatedAt.After(status.UpdatedAt):
cols = append(cols, "updated_at")
}
if pollChanged {
// Attached poll was changed.
cols = append(cols, "poll_id")
@ -1210,15 +1229,6 @@ func (d *Dereferencer) handleStatusEdit(
}
if edited {
// 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
@ -1265,8 +1275,8 @@ func (d *Dereferencer) handleStatusEdit(
status.EditIDs = append(status.EditIDs, edit.ID)
status.Edits = append(status.Edits, &edit)
// Add updated_at and edits to list of cols.
cols = append(cols, "updated_at", "edits")
// Add edit to list of cols.
cols = append(cols, "edits")
}
return cols, nil