Guard against outdated Updates

It is possible for an earlier Update to be received by us later.
For this, we now
(1) only allows Updates to poll counts if there is no updated field,
    or the updated field is the same as the last updated date or
    creation date;
(2) does not allow updating anything if the updated field
    is older than the last updated date or creation date;
(3) allows updating updatable fields otherwise (normal updates);
(4) if only the updated field is changed, it does not create
    a new history item on its own.
This commit is contained in:
Tusooa Zhu 2022-07-07 15:11:29 -04:00
commit 069554e925
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
3 changed files with 145 additions and 18 deletions

View file

@ -1596,7 +1596,7 @@ defmodule Pleroma.Web.CommonAPITest do
clear_config([:instance, :federating], true)
with_mock Pleroma.Web.Federator,
publish: fn p -> nil end do
publish: fn _p -> nil end do
{:ok, updated} = CommonAPI.update(user, activity, %{status: "updated 2 :#{emoji2}:"})
assert updated.data["object"]["content"] == "updated 2 :#{emoji2}:"