[Pleroma.Web.ActivityPub.Transmogrifier]: quick fix when tag is a Map
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 21 Sep 2018 12:46:49 +0000 (14:46 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Thu, 27 Sep 2018 18:00:46 +0000 (20:00 +0200)
lib/pleroma/web/activity_pub/transmogrifier.ex

index a37c8477fdc111f55dbeb96049d809070035001d..8b0d65b6f51ffaa05edaeca927ffed8fa0fd9073 100644 (file)
@@ -194,18 +194,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     object
   end
 
-  def fix_tag(object) do
+  def fix_tag(%{"tag" => tag} = object) when is_list(tag) do
     tags =
-      (object["tag"] || [])
+      tag
       |> Enum.filter(fn data -> data["type"] == "Hashtag" and data["name"] end)
       |> Enum.map(fn data -> String.slice(data["name"], 1..-1) end)
 
-    combined = (object["tag"] || []) ++ tags
+    combined = tag ++ tags
 
     object
     |> Map.put("tag", combined)
   end
 
+  def fix_tag(object) do
+    object
+  end
+
   # content map usually only has one language so this will do for now.
   def fix_content_map(%{"contentMap" => content_map} = object) do
     content_groups = Map.to_list(content_map)