fix(federation): handle fetch_actor with a map

For some reason

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-06-20 15:31:31 +02:00
parent 5cc5c9943c
commit 552ab4c80b
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -179,8 +179,10 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
def maybe_fetch_actor_and_attributed_to_id(_), do: {:error, :no_actor_found} def maybe_fetch_actor_and_attributed_to_id(_), do: {:error, :no_actor_found}
@spec fetch_actor(String.t()) :: {:ok, Actor.t()} | {:error, atom()} @spec fetch_actor(String.t() | map()) :: {:ok, Actor.t()} | {:error, atom()}
def fetch_actor(actor_url) do 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 case ActivityPubActor.get_or_fetch_actor_by_url(actor_url) do
{:ok, %Actor{suspended: false} = actor} -> {:ok, %Actor{suspended: false} = actor} ->
{:ok, actor} {:ok, actor}
@ -193,6 +195,8 @@ defmodule Mobilizon.Federation.ActivityStream.Converter.Utils do
end end
end end
def fetch_actor(_), do: {:error, :no_actor_found}
@spec process_pictures(map(), integer()) :: Keyword.t() @spec process_pictures(map(), integer()) :: Keyword.t()
def process_pictures(object, actor_id) do def process_pictures(object, actor_id) do
attachements = Map.get(object, "attachment", []) attachements = Map.get(object, "attachment", [])