Limit custom fields for old remote users
authorEgor Kislitsyn <egor@kislitsyn.com>
Wed, 7 Aug 2019 11:48:05 +0000 (18:48 +0700)
committerEgor Kislitsyn <egor@kislitsyn.com>
Wed, 14 Aug 2019 07:58:06 +0000 (14:58 +0700)
lib/pleroma/user/info.ex

index 47e7df911a785726661e5f4a1eec366645252097..45a39924b94853a377244d06ba2106fc6650b741 100644 (file)
@@ -423,9 +423,12 @@ defmodule Pleroma.User.Info do
   # ``fields`` is an array of mastodon profile field, containing ``{"name": "…", "value": "…"}``.
   # For example: [{"name": "Pronoun", "value": "she/her"}, …]
   def fields(%{fields: [], source_data: %{"attachment" => attachment}}) do
+    limit = Pleroma.Config.get([:instance, :max_remote_account_fields], 0)
+
     attachment
     |> Enum.filter(fn %{"type" => t} -> t == "PropertyValue" end)
     |> Enum.map(fn fields -> Map.take(fields, ["name", "value"]) end)
+    |> Enum.take(limit)
   end
 
   def fields(%{fields: fields}), do: fields