Fix type of fields_attributes
authorkPherox <admin@mail.kr-kp.com>
Sat, 24 Aug 2019 22:02:32 +0000 (07:02 +0900)
committerAriadne Conill <ariadne@dereferenced.org>
Sun, 6 Oct 2019 15:14:27 +0000 (15:14 +0000)
Convert tuple list to map list when parameters is `:urlencoded` or `:multipart`

lib/pleroma/web/mastodon_api/controllers/mastodon_api_controller.ex

index a789f8392dff7b2842fb24111a03e6efb0e640ba..4cf95a5812478f49649a27a98f01779f0718890b 100644 (file)
@@ -143,6 +143,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       |> Enum.concat(Formatter.get_emoji_map(emojis_text))
       |> Enum.dedup()
 
+    params =
+      if Map.has_key?(params, "fields_attributes") && Enum.all?(params["fields_attributes"], &is_tuple/1) do
+        Map.update!(params, "fields_attributes", &Enum.map(&1, fn {_, v} -> v end))
+      else
+        params
+      end
+
     info_params =
       [
         :no_rich_text,