Change to delete empty name field
authorkPherox <admin@mail.kr-kp.com>
Sat, 24 Aug 2019 22:04:46 +0000 (07:04 +0900)
committerAriadne Conill <ariadne@dereferenced.org>
Sun, 6 Oct 2019 15:14:31 +0000 (15:14 +0000)
lib/pleroma/web/mastodon_api/controllers/mastodon_api_controller.ex

index 4cf95a5812478f49649a27a98f01779f0718890b..f20105bee97af7b7ea0045b7ec370e52714b5a43 100644 (file)
@@ -144,8 +144,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       |> 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))
+      if Map.has_key?(params, "fields_attributes") do
+        Map.update!(params, "fields_attributes", fn fields ->
+          if Enum.all?(fields, &is_tuple/1) do
+            Enum.map(fields, fn {_, v} -> v end)
+          else
+            fields
+          end
+          |> Enum.filter(fn %{"name" => n} -> n != "" end)
+        end)
       else
         params
       end