Pleroma.Web.ActivityPub.Transmogrifier: Fix actor being a list of objects (Peertube)
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Wed, 1 Aug 2018 01:24:39 +0000 (03:24 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 21 Aug 2018 16:24:06 +0000 (18:24 +0200)
lib/pleroma/web/activity_pub/transmogrifier.ex

index e5fb6e033d708ee71b871233cc765cbda52e9003..39e2bb8a9985821f8b0dc98fe7eccb61da7abecf 100644 (file)
@@ -18,18 +18,18 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
   end
 
   def get_actor(%{"actor" => actor}) when is_list(actor) do
-    Enum.at(actor, 0)
+    if is_binary(Enum.at(actor, 0)) do
+      Enum.at(actor, 0)
+    else
+      Enum.find(actor, fn %{"type" => type} -> type == "Person" end)
+      |> Map.get("id")
+    end
   end
 
   def get_actor(%{"actor" => actor}) when is_map(actor) do
     actor["id"]
   end
 
-  def get_actor(%{"actor" => actor_list}) do
-    Enum.find(actor_list, fn %{"type" => type} -> type == "Person" end)
-    |> Map.get("id")
-  end
-
   @doc """
   Modifies an incoming AP object (mastodon format) to our internal format.
   """