Oban jobs should be discarded on permanent errors

This commit is contained in:
Mark Felder 2023-12-28 23:52:05 -05:00 committed by Floatingghost
parent c0532bcae0
commit fed7a78c77
2 changed files with 9 additions and 9 deletions

View file

@ -16,19 +16,19 @@ def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
:ok
{:error, :forbidden} ->
{:cancel, :forbidden}
{:discard, :forbidden}
{:error, :not_found} ->
{:cancel, :not_found}
{:discard, :not_found}
{:error, :allowed_depth} ->
{:cancel, :allowed_depth}
{:discard, :allowed_depth}
_ ->
:error
end
else
{:cancel, "Unreachable instance"}
{:discard, "Unreachable instance"}
end
end
end

View file

@ -41,19 +41,19 @@ defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
end
test "does not requeue a deleted object" do
assert {:cancel, _} =
assert {:discard, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @deleted_object_one}
})
assert {:cancel, _} =
assert {:discard, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @deleted_object_two}
})
end
test "does not requeue an unauthorized object" do
assert {:cancel, _} =
assert {:discard, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @unauthorized_object}
})
@ -64,7 +64,7 @@ test "does not fetch an unreachable instance" do
refute Instances.reachable?(@unreachable_object)
assert {:cancel, _} =
assert {:discard, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @unreachable_object}
})
@ -73,7 +73,7 @@ test "does not fetch an unreachable instance" do
test "does not requeue an object that exceeded depth" do
clear_config([:instance, :federation_incoming_replies_max_depth], 0)
assert {:cancel, _} =
assert {:discard, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @depth_object, "depth" => 1}
})