Add custom profile fields
This commit is contained in:
parent
744e2ce8b4
commit
e0ac5c7a66
6 changed files with 87 additions and 5 deletions
|
|
@ -156,6 +156,17 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||
end)
|
||||
end)
|
||||
|> add_if_present(params, "default_scope", :default_scope)
|
||||
|> add_if_present(params, "fields", :fields, fn fields ->
|
||||
fields =
|
||||
Enum.map(fields, fn field ->
|
||||
%{
|
||||
"name" => Formatter.html_escape(field["name"], "text/plain"),
|
||||
"value" => Formatter.html_escape(field["value"], "text/plain")
|
||||
}
|
||||
end)
|
||||
|
||||
{:ok, fields}
|
||||
end)
|
||||
|> add_if_present(params, "pleroma_settings_store", :pleroma_settings_store, fn value ->
|
||||
{:ok, Map.merge(user.info.pleroma_settings_store, value)}
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -93,10 +93,8 @@ 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)
|
||||
fields = User.Info.fields(user.info)
|
||||
fields_html = Enum.map(fields, fn f -> Map.update!(f, "value", &AutoLinker.link(&1)) end)
|
||||
|
||||
bio = HTML.filter_tags(user.bio, User.html_filter_policy(opts[:for]))
|
||||
|
||||
|
|
@ -119,11 +117,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
header: header,
|
||||
header_static: header,
|
||||
emojis: emojis,
|
||||
fields: fields,
|
||||
fields: fields_html,
|
||||
bot: bot,
|
||||
source: %{
|
||||
note: HTML.strip_tags((user.bio || "") |> String.replace("<br>", "\n")),
|
||||
sensitive: false,
|
||||
fields: fields,
|
||||
pleroma: %{}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue