Skip remote fetch jobs for unreachable instances

This commit is contained in:
Mark Felder 2023-12-26 16:28:05 -05:00 committed by Floatingghost
parent 6d368808d3
commit e2b04fac5a
2 changed files with 15 additions and 9 deletions

View file

@ -1,2 +1,3 @@
Remote object fetch failures will prevent the object fetch job from retrying if the object has been deleted or the fetch was denied with a 403 due to instance block behavior with authorized_fetch enabled.
Mark instances as unreachable when object fetch is denied due to instance block and authorized_fetch.
Skip fetching objects from unreachable instances.

View file

@ -3,12 +3,14 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.RemoteFetcherWorker do
alias Pleroma.Instances
alias Pleroma.Object.Fetcher
use Pleroma.Workers.WorkerHelper, queue: "remote_fetcher"
@impl Oban.Worker
def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
if Instances.reachable?(id) do
case Fetcher.fetch_object_from_id(id, depth: args["depth"]) do
{:ok, _object} ->
:ok
@ -22,5 +24,8 @@ def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
_ ->
:error
end
else
{:cancel, "Unreachable instance"}
end
end
end