transmogrfier: be more selective about Delete retry

If something else renders the Delete invalid,
there’s no point in retrying anyway
This commit is contained in:
Oneric 2024-12-18 01:27:32 +01:00
parent 92bf93a4f7
commit ac2327c8fc

View file

@ -560,17 +560,23 @@ defp handle_incoming_normalised(
Pipeline.common_pipeline(data, local: false) do Pipeline.common_pipeline(data, local: false) do
{:ok, activity} {:ok, activity}
else else
{:error, {:validate, _}} = e -> {:error, {:validate, {:error, %Ecto.Changeset{errors: errors}}}} = e ->
# Check if we have a create activity for this if errors[:object] == {"can't find object", []} do
with {:ok, object_id} <- ObjectValidators.ObjectID.cast(data["object"]), # Check if we have a create activity for this
%Activity{data: %{"actor" => actor}} <- # (e.g. from a db prune without --prune-activities)
Activity.create_by_object_ap_id(object_id) |> Repo.one(), # We'd still like to process side effects so insert a tombstone and retry
# We have one, insert a tombstone and retry with {:ok, object_id} <- ObjectValidators.ObjectID.cast(data["object"]),
{:ok, tombstone_data, _} <- Builder.tombstone(actor, object_id), %Activity{data: %{"actor" => actor}} <-
{:ok, _tombstone} <- Object.create(tombstone_data) do Activity.create_by_object_ap_id(object_id) |> Repo.one(),
handle_incoming(data) # We have one, insert a tombstone and retry
{:ok, tombstone_data, _} <- Builder.tombstone(actor, object_id),
{:ok, _tombstone} <- Object.create(tombstone_data) do
handle_incoming(data)
else
_ -> e
end
else else
_ -> e e
end end
{:error, _} = e -> {:error, _} = e ->