mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-29 17:46:15 -06:00
improve handling of remote status updated_at to fix previous cases
This commit is contained in:
parent
bc4c86ee6f
commit
9e6625d309
1 changed files with 21 additions and 11 deletions
|
|
@ -1157,6 +1157,25 @@ func (d *Dereferencer) handleStatusEdit(
|
||||||
edited = true
|
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 {
|
if pollChanged {
|
||||||
// Attached poll was changed.
|
// Attached poll was changed.
|
||||||
cols = append(cols, "poll_id")
|
cols = append(cols, "poll_id")
|
||||||
|
|
@ -1210,15 +1229,6 @@ func (d *Dereferencer) handleStatusEdit(
|
||||||
}
|
}
|
||||||
|
|
||||||
if edited {
|
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
|
// 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
|
||||||
|
|
@ -1265,8 +1275,8 @@ func (d *Dereferencer) handleStatusEdit(
|
||||||
status.EditIDs = append(status.EditIDs, edit.ID)
|
status.EditIDs = append(status.EditIDs, edit.ID)
|
||||||
status.Edits = append(status.Edits, &edit)
|
status.Edits = append(status.Edits, &edit)
|
||||||
|
|
||||||
// Add updated_at and edits to list of cols.
|
// Add edit to list of cols.
|
||||||
cols = append(cols, "updated_at", "edits")
|
cols = append(cols, "edits")
|
||||||
}
|
}
|
||||||
|
|
||||||
return cols, nil
|
return cols, nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue