commit: 9c0040124a9ea68cedca4959d32105ee6a6c3ee1
parent 5f6966cd9ff9c728d97a8e4075cba738ceca0aeb
Author: Mark Felder <feld@feld.me>
Date: Tue, 26 Dec 2023 16:28:05 -0500
Skip remote fetch jobs for unreachable instances
Diffstat:
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/changelog.d/handle_object_fetch_failures.change b/changelog.d/handle_object_fetch_failures.change
@@ -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.
diff --git a/lib/pleroma/workers/remote_fetcher_worker.ex b/lib/pleroma/workers/remote_fetcher_worker.ex
@@ -3,24 +3,29 @@
# 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
- case Fetcher.fetch_object_from_id(id, depth: args["depth"]) do
- {:ok, _object} ->
- :ok
+ if Instances.reachable?(id) do
+ case Fetcher.fetch_object_from_id(id, depth: args["depth"]) do
+ {:ok, _object} ->
+ :ok
- {:error, reason = "Object fetch has been denied"} ->
- {:cancel, reason}
+ {:error, reason = "Object fetch has been denied"} ->
+ {:cancel, reason}
- {:error, reason = "Object has been deleted"} ->
- {:cancel, reason}
+ {:error, reason = "Object has been deleted"} ->
+ {:cancel, reason}
- _ ->
- :error
+ _ ->
+ :error
+ end
+ else
+ {:cancel, "Unreachable instance"}
end
end