aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHaelwenn <git.pleroma.social@hacktivis.me>2018-09-28 09:25:27 +0000
committerHaelwenn <git.pleroma.social@hacktivis.me>2018-09-28 09:25:27 +0000
commit34b6d444d61c40afe34e06980ab3566884504a2b (patch)
tree6a64a81e108ff1875b3f3621267541ab8c201a3e /lib
parentdbc9feecbf11b696e984b40cbdf9ccde69cf469c (diff)
parenta74daabfae5ed149942b5afc64982d3e2ca95b11 (diff)
downloadpleroma-34b6d444d61c40afe34e06980ab3566884504a2b.tar.gz
Merge branch 'feature/twitter_api/fields' into 'develop'
[Pleroma.Web.TwitterAPI.UserView]: Add mastodon-fields in "fields" See merge request pleroma/pleroma!360
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/twitter_api/views/user_view.ex10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/pleroma/web/twitter_api/views/user_view.ex b/lib/pleroma/web/twitter_api/views/user_view.ex
index cfbaef4c9..a662f83b6 100644
--- a/lib/pleroma/web/twitter_api/views/user_view.ex
+++ b/lib/pleroma/web/twitter_api/views/user_view.ex
@@ -37,6 +37,13 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
{String.trim(name, ":"), url}
end)
+ # ``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)
+
data = %{
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
"description" => HTML.strip_tags((user.bio || "") |> String.replace("<br>", "\n")),
@@ -65,7 +72,8 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
"is_local" => user.local,
"locked" => !!user.info["locked"],
"default_scope" => user.info["default_scope"] || "public",
- "no_rich_text" => user.info["no_rich_text"] || false
+ "no_rich_text" => user.info["no_rich_text"] || false,
+ "fields" => fields
}
if assigns[:token] do