From c95941e64de3350594a2c5ceeb21c9c5e384451f Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 18 Jun 2018 21:51:22 +0000 Subject: [PATCH] activitypub transmogrifier: fix handling of contentMap. --- lib/pleroma/web/activity_pub/transmogrifier.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 300e0fcdd..30cd70fb6 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -24,6 +24,7 @@ def fix_object(object) 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 @@ def fix_tag(object) 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