logo

pleroma

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

remote_fetcher_worker.ex (1098B)


  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 Oban.Worker, queue: :background, unique: [period: :infinity]
  7. @impl true
  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. {:allowed_depth, false} ->
  13. {:cancel, :allowed_depth}
  14. {:containment, reason} ->
  15. {:cancel, reason}
  16. {:transmogrifier, reason} ->
  17. {:cancel, reason}
  18. {:fetch, {:error, :forbidden = reason}} ->
  19. {:cancel, reason}
  20. {:fetch, {:error, :not_found = reason}} ->
  21. {:cancel, reason}
  22. {:fetch, {:error, {:content_type, _}} = reason} ->
  23. {:cancel, reason}
  24. {:fetch, {:error, reason}} ->
  25. {:error, reason}
  26. {:error, _} = e ->
  27. e
  28. end
  29. end
  30. @impl true
  31. def timeout(_job), do: :timer.seconds(15)
  32. end