[Pleroma.Web.MastodonAPI.AccountView]: Add fields support
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Fri, 10 Aug 2018 00:41:01 +0000 (02:41 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 27 Aug 2018 13:09:05 +0000 (15:09 +0200)
lib/pleroma/web/mastodon_api/views/account_view.ex

index 9dd635a63ece60cace612e049949d1237d4bf973..634985fb6b73d96b176565897257d2ceb20f8a75 100644 (file)
@@ -27,6 +27,11 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
         }
       end)
 
+    fields =
+      (user.info["source_data"]["attachment"] || [])
+      |> Enum.filter(fn %{"type" => t} -> t == "PropertyValue" end)
+      |> Enum.map(fn fields -> Map.take(fields, ["name", "value"]) end)
+
     %{
       id: to_string(user.id),
       username: hd(String.split(user.nickname, "@")),
@@ -44,7 +49,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       header: header,
       header_static: header,
       emojis: emojis,
-      fields: [],
+      fields: fields,
       bot: bot,
       source: %{
         note: "",