Oban jobs should be discarded on permanent errors
This commit is contained in:
parent
aa070c7daf
commit
f17f92105b
|
@ -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
|
||||
|
||||
|
|
|
@ -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}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue