Merge branch 'tusooa/oban-common-pipeline' into 'develop'
Stop oban from retrying if validating errors occur when processing incoming data See merge request pleroma/pleroma!3844
This commit is contained in:
parent
fd46f83d2d
commit
22b72cd6b8
@ -13,6 +13,9 @@ defmodule Pleroma.Workers.ReceiverWorker do
|
|||||||
{:ok, res}
|
{:ok, res}
|
||||||
else
|
else
|
||||||
{:error, :origin_containment_failed} -> {:cancel, :origin_containment_failed}
|
{:error, :origin_containment_failed} -> {:cancel, :origin_containment_failed}
|
||||||
|
{:error, :already_present} -> {:cancel, :already_present}
|
||||||
|
{:error, {:validate_object, reason}} -> {:cancel, reason}
|
||||||
|
{:error, {:error, {:validate, reason}}} -> {:cancel, reason}
|
||||||
{:error, {:reject, reason}} -> {:cancel, reason}
|
{:error, {:reject, reason}} -> {:cancel, reason}
|
||||||
e -> e
|
e -> e
|
||||||
end
|
end
|
||||||
|
@ -133,7 +133,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||||||
assert {:ok, _activity} = ObanHelpers.perform(job)
|
assert {:ok, _activity} = ObanHelpers.perform(job)
|
||||||
|
|
||||||
assert {:ok, job} = Federator.incoming_ap_doc(params)
|
assert {:ok, job} = Federator.incoming_ap_doc(params)
|
||||||
assert {:error, :already_present} = ObanHelpers.perform(job)
|
assert {:cancel, :already_present} = ObanHelpers.perform(job)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "rejects incoming AP docs with incorrect origin" do
|
test "rejects incoming AP docs with incorrect origin" do
|
||||||
|
@ -11,7 +11,7 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
|
|||||||
|
|
||||||
alias Pleroma.Workers.ReceiverWorker
|
alias Pleroma.Workers.ReceiverWorker
|
||||||
|
|
||||||
test "it ignores MRF reject" do
|
test "it does not retry MRF reject" do
|
||||||
params = insert(:note).data
|
params = insert(:note).data
|
||||||
|
|
||||||
with_mock Pleroma.Web.ActivityPub.Transmogrifier,
|
with_mock Pleroma.Web.ActivityPub.Transmogrifier,
|
||||||
@ -22,4 +22,31 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it does not retry ObjectValidator reject" do
|
||||||
|
params =
|
||||||
|
insert(:note_activity).data
|
||||||
|
|> Map.put("id", Pleroma.Web.ActivityPub.Utils.generate_activity_id())
|
||||||
|
|> Map.put("object", %{
|
||||||
|
"type" => "Note",
|
||||||
|
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id()
|
||||||
|
})
|
||||||
|
|
||||||
|
with_mock Pleroma.Web.ActivityPub.ObjectValidator, [:passthrough],
|
||||||
|
validate: fn _, _ -> {:error, %Ecto.Changeset{}} end do
|
||||||
|
assert {:cancel, {:error, %Ecto.Changeset{}}} =
|
||||||
|
ReceiverWorker.perform(%Oban.Job{
|
||||||
|
args: %{"op" => "incoming_ap_doc", "params" => params}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it does not retry duplicates" do
|
||||||
|
params = insert(:note_activity).data
|
||||||
|
|
||||||
|
assert {:cancel, :already_present} =
|
||||||
|
ReceiverWorker.perform(%Oban.Job{
|
||||||
|
args: %{"op" => "incoming_ap_doc", "params" => params}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user