2020-01-25 00:47:30 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-01-25 00:47:30 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Workers.RemoteFetcherWorker do
|
|
|
|
alias Pleroma.Object.Fetcher
|
|
|
|
|
|
|
|
use Pleroma.Workers.WorkerHelper, queue: "remote_fetcher"
|
|
|
|
|
|
|
|
@impl Oban.Worker
|
2020-06-23 06:09:01 -06:00
|
|
|
def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
|
2024-01-14 11:23:17 -07:00
|
|
|
case Fetcher.fetch_object_from_id(id, depth: args["depth"]) do
|
|
|
|
{:ok, _object} ->
|
|
|
|
:ok
|
2023-12-26 13:54:14 -07:00
|
|
|
|
2024-01-14 11:23:17 -07:00
|
|
|
{:error, :forbidden} ->
|
|
|
|
{:discard, :forbidden}
|
2023-12-26 13:54:14 -07:00
|
|
|
|
2024-01-14 11:23:17 -07:00
|
|
|
{:error, :not_found} ->
|
|
|
|
{:discard, :not_found}
|
2023-12-26 14:05:44 -07:00
|
|
|
|
2024-01-14 11:23:17 -07:00
|
|
|
{:error, :allowed_depth} ->
|
|
|
|
{:discard, :allowed_depth}
|
2023-12-27 20:28:41 -07:00
|
|
|
|
2024-04-13 16:55:26 -06:00
|
|
|
{:error, :invalid_uri_scheme} ->
|
|
|
|
{:discard, :invalid_uri_scheme}
|
|
|
|
|
|
|
|
{:error, :local_resource} ->
|
|
|
|
{:discard, :local_resource}
|
|
|
|
|
|
|
|
{:reject, _} ->
|
|
|
|
{:discard, :reject}
|
|
|
|
|
|
|
|
{:error, :id_mismatch} ->
|
|
|
|
{:discard, :id_mismatch}
|
|
|
|
|
2024-01-14 11:23:17 -07:00
|
|
|
_ ->
|
|
|
|
:error
|
2023-12-26 13:54:14 -07:00
|
|
|
end
|
2020-01-25 00:47:30 -07:00
|
|
|
end
|
|
|
|
end
|