forked from mirrors/akkoma
Skip remote fetch jobs for unreachable instances
This commit is contained in:
parent
6d368808d3
commit
e2b04fac5a
|
@ -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.
|
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.
|
Mark instances as unreachable when object fetch is denied due to instance block and authorized_fetch.
|
||||||
|
Skip fetching objects from unreachable instances.
|
||||||
|
|
|
@ -3,24 +3,29 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Workers.RemoteFetcherWorker do
|
defmodule Pleroma.Workers.RemoteFetcherWorker do
|
||||||
|
alias Pleroma.Instances
|
||||||
alias Pleroma.Object.Fetcher
|
alias Pleroma.Object.Fetcher
|
||||||
|
|
||||||
use Pleroma.Workers.WorkerHelper, queue: "remote_fetcher"
|
use Pleroma.Workers.WorkerHelper, queue: "remote_fetcher"
|
||||||
|
|
||||||
@impl Oban.Worker
|
@impl Oban.Worker
|
||||||
def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
|
def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
|
||||||
case Fetcher.fetch_object_from_id(id, depth: args["depth"]) do
|
if Instances.reachable?(id) do
|
||||||
{:ok, _object} ->
|
case Fetcher.fetch_object_from_id(id, depth: args["depth"]) do
|
||||||
:ok
|
{:ok, _object} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
{:error, reason = "Object fetch has been denied"} ->
|
{:error, reason = "Object fetch has been denied"} ->
|
||||||
{:cancel, reason}
|
{:cancel, reason}
|
||||||
|
|
||||||
{:error, reason = "Object has been deleted"} ->
|
{:error, reason = "Object has been deleted"} ->
|
||||||
{:cancel, reason}
|
{:cancel, reason}
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
:error
|
:error
|
||||||
|
end
|
||||||
|
else
|
||||||
|
{:cancel, "Unreachable instance"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue