in dev, allow dev FE
[akkoma] / lib / pleroma / web / activity_pub / activity_pub.ex
index 3f46a8ecb18d6f35c2785f268311b69dff153457..8e55df0d8cac2fc955b2394e197be133167ffe89 100644 (file)
@@ -739,9 +739,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     |> fetch_activities(params, :offset)
   end
 
-  defp user_activities_recipients(%{godmode: true}), do: []
+  def user_activities_recipients(%{godmode: true}), do: []
 
-  defp user_activities_recipients(%{reading_user: reading_user}) do
+  def user_activities_recipients(%{reading_user: reading_user}) do
     if not is_nil(reading_user) and reading_user.local do
       [
         Constants.as_public(),
@@ -1531,6 +1531,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   defp normalize_image(urls) when is_list(urls), do: urls |> List.first() |> normalize_image()
   defp normalize_image(_), do: nil
 
+  defp normalize_also_known_as(aka) when is_list(aka), do: aka
+  defp normalize_also_known_as(aka) when is_binary(aka), do: [aka]
+  defp normalize_also_known_as(nil), do: []
+
   defp object_to_user_data(data, additional) do
     fields =
       data
@@ -1576,6 +1580,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     also_known_as =
       data
       |> Map.get("alsoKnownAs", [])
+      |> normalize_also_known_as()
       |> Enum.filter(fn url ->
         case URI.parse(url) do
           %URI{scheme: "http"} -> true
@@ -1711,7 +1716,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       {:ok, maybe_update_follow_information(data)}
     else
       # If this has been deleted, only log a debug and not an error
-      {:error, "Object has been deleted" = e} ->
+      {:error, {"Object has been deleted", _, _} = e} ->
         Logger.debug("Could not decode user at fetch #{ap_id}, #{inspect(e)}")
         {:error, e}