diff --git a/lib/federation/activity_pub/actor.ex b/lib/federation/activity_pub/actor.ex index 61dec80f0..578628cf3 100644 --- a/lib/federation/activity_pub/actor.ex +++ b/lib/federation/activity_pub/actor.ex @@ -29,6 +29,8 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do end def get_or_fetch_actor_by_url(url, preload) do + Logger.debug("Getting or fetching actor by URL #{url}") + case Actors.get_actor_by_url(url, preload) do {:ok, %Actor{} = cached_actor} -> if Actors.needs_update?(cached_actor) do @@ -51,6 +53,8 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do @spec make_actor_from_url(url :: String.t(), options :: Keyword.t()) :: {:ok, Actor.t()} | {:error, make_actor_errors | Ecto.Changeset.t()} def make_actor_from_url(url, options \\ []) do + Logger.debug("Making actor from url #{url}") + if are_same_origin?(url, Endpoint.url()) do {:error, :actor_is_local} else @@ -75,6 +79,8 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do @spec find_or_make_actor_from_nickname(nickname :: String.t(), type :: atom() | nil) :: {:ok, Actor.t()} | {:error, make_actor_errors | WebFinger.finger_errors()} def find_or_make_actor_from_nickname(nickname, type \\ nil) do + Logger.debug("Finding or making actor from nickname #{nickname}") + case Actors.get_actor_by_name_with_preload(nickname, type) do %Actor{url: actor_url} = actor -> if Actors.needs_update?(actor) do @@ -98,8 +104,11 @@ defmodule Mobilizon.Federation.ActivityPub.Actor do @spec make_actor_from_nickname(nickname :: String.t(), preload :: boolean) :: {:ok, Actor.t()} | {:error, make_actor_errors | WebFinger.finger_errors()} def make_actor_from_nickname(nickname, preload \\ false) do + Logger.debug("Fingering actor from nickname #{nickname}") + case WebFinger.finger(nickname) do {:ok, url} when is_binary(url) -> + Logger.debug("Matched #{nickname} to URL #{url}, now making actor") make_actor_from_url(url, preload: preload) {:error, e} -> diff --git a/lib/federation/activity_pub/refresher.ex b/lib/federation/activity_pub/refresher.ex index 21a49781b..bfa4f6c16 100644 --- a/lib/federation/activity_pub/refresher.ex +++ b/lib/federation/activity_pub/refresher.ex @@ -36,6 +36,8 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do end def refresh_profile(%Actor{type: type, url: url}) when type in [:Person, :Application] do + Logger.debug("Refreshing profile #{url}") + case ActivityPubActor.make_actor_from_url(url) do {:error, error} -> {:error, error} @@ -52,6 +54,8 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do @spec fetch_group(String.t(), Actor.t()) :: :ok | {:error, fetch_actor_errors} def fetch_group(group_url, %Actor{} = on_behalf_of) do + Logger.debug("Fetching group #{group_url}") + case ActivityPubActor.make_actor_from_url(group_url, on_behalf_of: on_behalf_of) do {:error, err} when err in [:actor_deleted, :http_error, :json_decode_error, :actor_is_local] -> diff --git a/lib/web/plugs/mapped_signature_to_identity.ex b/lib/web/plugs/mapped_signature_to_identity.ex index 8c63b841c..550e1e6f9 100644 --- a/lib/web/plugs/mapped_signature_to_identity.ex +++ b/lib/web/plugs/mapped_signature_to_identity.ex @@ -34,6 +34,8 @@ defmodule Mobilizon.Web.Plugs.MappedSignatureToIdentity do @spec actor_from_key_id(Plug.Conn.t()) :: Actor.t() | nil defp actor_from_key_id(conn) do + Logger.debug("Determining actor from connection signature") + with key_actor_id when is_binary(key_actor_id) <- key_id_from_conn(conn), {:ok, %Actor{} = actor} <- ActivityPubActor.get_or_fetch_actor_by_url(key_actor_id) do actor