From 552ab4c80b2f99095028ab3685c71ff9efdb94eb Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Jun 2023 15:31:31 +0200 Subject: [PATCH] fix(federation): handle fetch_actor with a map For some reason Signed-off-by: Thomas Citharel --- lib/federation/activity_stream/converter/utils.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/federation/activity_stream/converter/utils.ex b/lib/federation/activity_stream/converter/utils.ex index 3bba5f3dc..29ca105bf 100644 --- a/lib/federation/activity_stream/converter/utils.ex +++ b/lib/federation/activity_stream/converter/utils.ex @@ -179,8 +179,10 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do def maybe_fetch_actor_and_attributed_to_id(_), do: {:error, :no_actor_found} - @spec fetch_actor(String.t()) :: {:ok, Actor.t()} | {:error, atom()} - def fetch_actor(actor_url) do + @spec fetch_actor(String.t() | map()) :: {:ok, Actor.t()} | {:error, atom()} + def fetch_actor(%{"id" => actor_url}) when is_binary(actor_url), do: fetch_actor(actor_url) + + def fetch_actor(actor_url) when is_binary(actor_url) do case ActivityPubActor.get_or_fetch_actor_by_url(actor_url) do {:ok, %Actor{suspended: false} = actor} -> {:ok, actor} @@ -193,6 +195,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do end end + def fetch_actor(_), do: {:error, :no_actor_found} + @spec process_pictures(map(), integer()) :: Keyword.t() def process_pictures(object, actor_id) do attachements = Map.get(object, "attachment", [])