logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

remote_fetcher_worker.ex (803B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Workers.RemoteFetcherWorker do
  5. alias Pleroma.Object.Fetcher
  6. use Pleroma.Workers.WorkerHelper, queue: "remote_fetcher"
  7. @impl Oban.Worker
  8. def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
  9. case Fetcher.fetch_object_from_id(id, depth: args["depth"]) do
  10. {:ok, _object} ->
  11. :ok
  12. {:error, :forbidden} ->
  13. {:discard, :forbidden}
  14. {:error, :not_found} ->
  15. {:discard, :not_found}
  16. {:error, :allowed_depth} ->
  17. {:discard, :allowed_depth}
  18. _ ->
  19. :error
  20. end
  21. end
  22. @impl Oban.Worker
  23. def timeout(_job), do: :timer.seconds(10)
  24. end