activitypub transmogrifier: fix handling of contentMap.
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 18 Jun 2018 21:51:22 +0000 (21:51 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 18 Jun 2018 22:14:50 +0000 (22:14 +0000)
lib/pleroma/web/activity_pub/transmogrifier.ex

index 300e0fcdd350ecbec0a2b8b64a6b148258d7cdb2..30cd70fb656096df97ee86fe285d8fbe3a174dc3 100644 (file)
@@ -24,6 +24,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     |> fix_in_reply_to
     |> fix_emoji
     |> fix_tag
+    |> fix_content_map
   end
 
   def fix_in_reply_to(%{"inReplyTo" => in_reply_to_id} = object)
@@ -107,6 +108,17 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
     |> Map.put("tag", combined)
   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)
+    {_, content} = Enum.at(content_groups, 0)
+
+    object
+    |> Map.put("content", content)
+  end
+
+  def fix_content_map(object), do: object
+
   # TODO: validate those with a Ecto scheme
   # - tags
   # - emoji