forked from AkkomaGang/akkoma
Ensure object id doesn’t change on refetch
This commit is contained in:
parent
3e134b07fa
commit
9061d148be
1 changed files with 2 additions and 0 deletions
|
@ -117,10 +117,12 @@ defp reinject_object(%Object{} = object, new_data) do
|
|||
def refetch_object(%Object{data: %{"id" => id}} = object) do
|
||||
with {:local, false} <- {:local, Object.local?(object)},
|
||||
{:ok, new_data} <- fetch_and_contain_remote_object_from_id(id),
|
||||
{:id, true} <- {:id, new_data["id"] == id},
|
||||
{:ok, object} <- reinject_object(object, new_data) do
|
||||
{:ok, object}
|
||||
else
|
||||
{:local, true} -> {:ok, object}
|
||||
{:id, false} -> {:error, "Object id changed on refetch"}
|
||||
e -> {:error, e}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue