From d7ab4d9b0b439c5aa7092b3ba5c0930c48e0a590 Mon Sep 17 00:00:00 2001 From: Oneric Date: Wed, 18 Dec 2024 01:27:32 +0100 Subject: [PATCH] transmogrfier: be more selective about Delete retry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If something else renders the Delete invalid, there’s no point in retrying anyway --- .../web/activity_pub/transmogrifier.ex | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index bb6e2cb0d..7954d979c 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -560,17 +560,23 @@ defp handle_incoming_normalised( Pipeline.common_pipeline(data, local: false) do {:ok, activity} else - {:error, {:validate, _}} = e -> - # Check if we have a create activity for this - with {:ok, object_id} <- ObjectValidators.ObjectID.cast(data["object"]), - %Activity{data: %{"actor" => actor}} <- - Activity.create_by_object_ap_id(object_id) |> Repo.one(), - # 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) + {: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 + # (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"]), + %Activity{data: %{"actor" => actor}} <- + Activity.create_by_object_ap_id(object_id) |> Repo.one(), + # 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 - _ -> e + e end {:error, _} = e ->