From a5adb251ab101e7ad1084a772b66b049998c72a5 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 10 Aug 2018 02:41:01 +0200 Subject: [PATCH] [Pleroma.Web.MastodonAPI.AccountView]: Add fields support --- lib/pleroma/web/mastodon_api/views/account_view.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 9dd635a63..634985fb6 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -27,6 +27,11 @@ def render("account.json", %{user: user}) 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 @@ def render("account.json", %{user: user}) do header: header, header_static: header, emojis: emojis, - fields: [], + fields: fields, bot: bot, source: %{ note: "",