aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-07-25 19:33:18 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-08-14 14:52:54 +0700
commita22f540fc42dd941631e94fe931d1f655b2904a1 (patch)
tree9e354980165e25063f94aeafdd030ad0bb80876c
parent069951722f9b674a759e0b8683aff9c03019467b (diff)
downloadpleroma-a22f540fc42dd941631e94fe931d1f655b2904a1.tar.gz
Add custom fields to TwitterAPI.UserView
-rw-r--r--lib/pleroma/user/info.ex2
-rw-r--r--lib/pleroma/web/twitter_api/views/user_view.ex7
2 files changed, 3 insertions, 6 deletions
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex
index fa57052fb..98b894223 100644
--- a/lib/pleroma/user/info.ex
+++ b/lib/pleroma/user/info.ex
@@ -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)
diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex
index 8d8892068..3681773be 100644
--- a/lib/pleroma/web/twitter_api/views/user_view.ex
+++ b/lib/pleroma/web/twitter_api/views/user_view.ex
@@ -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 =
%{