diff --git a/lib/clacks/activitypub/fetcher.ex b/lib/clacks/activitypub/fetcher.ex index 0ccf273..3832baf 100644 --- a/lib/clacks/activitypub/fetcher.ex +++ b/lib/clacks/activitypub/fetcher.ex @@ -19,7 +19,8 @@ defmodule Clacks.ActivityPub.Fetcher do def fetch_object(id) do %{host: id_host} = URI.parse(id) - with %{"actor" => remote_actor} = object <- fetch(id), + with object when is_map(object) <- fetch(id), + remote_actor when is_binary(remote_actor) <- get_actor(object), %{host: ^id_host} <- URI.parse(remote_actor) do object else @@ -48,4 +49,9 @@ defmodule Clacks.ActivityPub.Fetcher do nil end end + + @spec get_actor(data :: map()) :: String.t() | nil + defp get_actor(%{"actor" => actor}) when is_binary(actor), do: actor + defp get_actor(%{"attributedTo" => actor}) when is_binary(actor), do: actor + defp get_actor(_), do: nil end