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,8 +560,11 @@ 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 ->
if errors[:object] == {"can't find object", []} do
# Check if we have a create activity for this # Check if we have a create activity for this
# (e.g. from a db prune without --prune-activities)
# We'd still like to process side effects so insert a tombstone and retry
with {:ok, object_id} <- ObjectValidators.ObjectID.cast(data["object"]), with {:ok, object_id} <- ObjectValidators.ObjectID.cast(data["object"]),
%Activity{data: %{"actor" => actor}} <- %Activity{data: %{"actor" => actor}} <-
Activity.create_by_object_ap_id(object_id) |> Repo.one(), Activity.create_by_object_ap_id(object_id) |> Repo.one(),
@ -572,6 +575,9 @@ defp handle_incoming_normalised(
else else
_ -> e _ -> e
end end
else
e
end
{:error, _} = e -> {:error, _} = e ->
e e