Prevent requeuing Remote Fetcher jobs that exceed thread depth

This commit is contained in:
Mark Felder 2023-12-27 22:28:41 -05:00
commit ad0a5deb67
5 changed files with 21 additions and 4 deletions

View file

@ -101,8 +101,7 @@ defmodule Pleroma.Object.FetcherTest do
test "it returns thread depth exceeded error if thread depth is exceeded" do
clear_config([:instance, :federation_incoming_replies_max_depth], 0)
assert {:error, "Max thread distance exceeded."} =
Fetcher.fetch_object_from_id(@ap_id, depth: 1)
assert {:error, :allowed_depth} = Fetcher.fetch_object_from_id(@ap_id, depth: 1)
end
test "it fetches object if max thread depth is restricted to 0 and depth is not specified" do

View file

@ -13,6 +13,7 @@ defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
@deleted_object_two "https://deleted-410.example.com/"
@unauthorized_object "https://unauthorized.example.com/"
@unreachable_object "https://unreachable.example.com/"
@depth_object "https://depth.example.com/"
describe "it does not" do
setup do
@ -31,6 +32,11 @@ defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
%Tesla.Env{
status: 403
}
%{method: :get, url: @depth_object} ->
%Tesla.Env{
status: 200
}
end)
end
@ -63,5 +69,14 @@ defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
args: %{"op" => "fetch_remote", "id" => @unreachable_object}
})
end
test "requeue an object that exceeded depth" do
clear_config([:instance, :federation_incoming_replies_max_depth], 0)
assert {:cancel, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @depth_object, "depth" => 1}
})
end
end
end