logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: ea0ec5fbcf2e17d97f323bcb6872df48d5e42714
parent 5f1d70736711275ac9f0c95e5ada4cb2f1a96e11
Author: Mark Felder <feld@feld.me>
Date:   Tue, 26 Dec 2023 14:20:33 -0500

Remove Fetcher.fetch_object_from_id!/2

It was only being called once and can be replaced with a case statement.

Diffstat:

Mlib/pleroma/object.ex5++++-
Mlib/pleroma/object/fetcher.ex26+++++---------------------
2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/lib/pleroma/object.ex b/lib/pleroma/object.ex @@ -177,7 +177,10 @@ defmodule Pleroma.Object do ap_id Keyword.get(options, :fetch) -> - Fetcher.fetch_object_from_id!(ap_id, options) + case Fetcher.fetch_object_from_id(ap_id, options) do + {:ok, object} -> object + _ -> nil + end true -> get_cached_by_ap_id(ap_id) diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex @@ -79,9 +79,11 @@ defmodule Pleroma.Object.Fetcher do {:error, "Object containment failed."} {:transmogrifier, {:error, {:reject, e}}} -> + Logger.info("Rejected #{id} while fetching: #{inspect(e)}") {:reject, e} {:transmogrifier, {:reject, e}} -> + Logger.info("Rejected #{id} while fetching: #{inspect(e)}") {:reject, e} {:transmogrifier, _} = e -> @@ -97,10 +99,12 @@ defmodule Pleroma.Object.Fetcher do {:ok, object} {:fetch, {:error, error}} -> + Logger.error("Error while fetching #{id}: #{inspect(error)}") {:error, error} e -> - e + Logger.error("Error while fetching #{id}: #{inspect(e)}") + {:error, e} end end @@ -117,26 +121,6 @@ defmodule Pleroma.Object.Fetcher do |> Maps.put_if_present("bcc", data["bcc"]) end - def fetch_object_from_id!(id, options \\ []) do - with {:ok, object} <- fetch_object_from_id(id, options) do - object - else - {:error, %Tesla.Mock.Error{}} -> - nil - - {:error, "Object has been deleted"} -> - nil - - {:reject, reason} -> - Logger.info("Rejected #{id} while fetching: #{inspect(reason)}") - nil - - e -> - Logger.error("Error while fetching #{id}: #{inspect(e)}") - nil - end - end - defp make_signature(id, date) do uri = URI.parse(id)