summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2024-12-24 21:16:49 +0000
committerLibravatar GitHub <noreply@github.com>2024-12-24 21:16:49 +0000
commit0784aa3218934dea46c2fa501696e7f32696168b (patch)
treef69af51af9ec809b04d7c09e7b95ee98b0920ee0 /internal/federation/dereferencing
parent[feature] add support for clients editing statuses and fetching status revisi... (diff)
downloadgotosocial-0784aa3218934dea46c2fa501696e7f32696168b.tar.xz
[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
Diffstat (limited to 'internal/federation/dereferencing')
-rw-r--r--internal/federation/dereferencing/status.go26
1 files changed, 19 insertions, 7 deletions
diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go
index 0a75a4802..223389ad7 100644
--- a/internal/federation/dereferencing/status.go
+++ b/internal/federation/dereferencing/status.go
@@ -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