Add custom fields to TwitterAPI.UserView
authorEgor Kislitsyn <egor@kislitsyn.com>
Thu, 25 Jul 2019 12:33:18 +0000 (19:33 +0700)
committerEgor Kislitsyn <egor@kislitsyn.com>
Wed, 14 Aug 2019 07:52:54 +0000 (14:52 +0700)
lib/pleroma/user/info.ex
lib/pleroma/web/twitter_api/views/user_view.ex

index fa57052fb3f39bd6ca072d2ed951c116c424127c..98b894223b17f85d8eab4cdb72a3e9be9c805316 100644 (file)
@@ -407,6 +407,8 @@ defmodule Pleroma.User.Info do
     cast(info, params, [:muted_reblogs])
   end
 
+  # ``fields`` is an array of mastodon profile field, containing ``{"name": "…", "value": "…"}``.
+  # For example: [{"name": "Pronoun", "value": "she/her"}, …]
   def fields(%{source_data: %{"attachment" => attachment}}) do
     attachment
     |> Enum.filter(fn %{"type" => t} -> t == "PropertyValue" end)
index 8d88920685f8cd03dfe37ba72ec10cab932c3a5c..3681773bef83e32d0b272acd40f8a8c0f7abdb64 100644 (file)
@@ -74,12 +74,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
       |> HTML.filter_tags(User.html_filter_policy(for_user))
       |> Formatter.emojify(emoji)
 
-    # ``fields`` is an array of mastodon profile field, containing ``{"name": "…", "value": "…"}``.
-    # For example: [{"name": "Pronoun", "value": "she/her"}, …]
-    fields =
-      (user.info.source_data["attachment"] || [])
-      |> Enum.filter(fn %{"type" => t} -> t == "PropertyValue" end)
-      |> Enum.map(fn fields -> Map.take(fields, ["name", "value"]) end)
+    fields = User.Info.fields(user.info)
 
     data =
       %{