mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 07:12:25 -05:00
[bugfix] small editing tweaks (#3631)
* ensure edited_at isn't set on boost wrapper statuses * improve handling of remote status updated_at to fix previous cases * formatting * add remote status published / updated field validation checks, handle appropriately in handleStatusEdit() * specifically allowed updated to be equal to published * only check creation date change when an existing status
This commit is contained in:
parent
fe8d5f2307
commit
0784aa3218
3 changed files with 33 additions and 12 deletions
|
|
@ -505,6 +505,12 @@ func (d *Dereferencer) enrichStatus(
|
|||
latestStatus.ID = id.NewULIDFromTime(latestStatus.CreatedAt)
|
||||
} else {
|
||||
|
||||
// Ensure that status isn't trying to re-date itself.
|
||||
if !latestStatus.CreatedAt.Equal(status.CreatedAt) {
|
||||
err := gtserror.Newf("status %s 'published' changed", uri)
|
||||
return nil, nil, gtserror.SetMalformed(err)
|
||||
}
|
||||
|
||||
// Reuse existing status ID.
|
||||
latestStatus.ID = status.ID
|
||||
}
|
||||
|
|
@ -1210,12 +1216,12 @@ 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) {
|
||||
// ensure that updated_at hasn't remained the same
|
||||
// but an edit was received. manually intervene here.
|
||||
if status.UpdatedAt.Equal(existing.UpdatedAt) ||
|
||||
status.CreatedAt.Equal(status.UpdatedAt) {
|
||||
|
||||
// Else fallback to now as update time.
|
||||
// Simply use current fetching time.
|
||||
status.UpdatedAt = status.FetchedAt
|
||||
}
|
||||
|
||||
|
|
@ -1265,8 +1271,14 @@ 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")
|
||||
}
|
||||
|
||||
if !existing.UpdatedAt.Equal(status.UpdatedAt) {
|
||||
// Whether status edited or not,
|
||||
// updated_at column has changed.
|
||||
cols = append(cols, "updated_at")
|
||||
}
|
||||
|
||||
return cols, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue