aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/mastodon_api/views
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/mastodon_api/views')
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex9
-rw-r--r--lib/pleroma/web/mastodon_api/views/filter_view.ex27
2 files changed, 35 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index 7bc32e688..85aac493f 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -13,6 +13,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
image = User.avatar_url(user) |> MediaProxy.url()
header = User.banner_url(user) |> MediaProxy.url()
user_info = User.user_info(user)
+ bot = (user.info["source_data"]["type"] || "Person") in ["Application", "Service"]
emojis =
(user.info["source_data"]["tag"] || [])
@@ -26,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: username_from_nickname(user.nickname),
@@ -43,7 +49,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
header: header,
header_static: header,
emojis: emojis,
- fields: [],
+ fields: fields,
+ bot: bot,
source: %{
note: "",
privacy: user_info.default_scope,
diff --git a/lib/pleroma/web/mastodon_api/views/filter_view.ex b/lib/pleroma/web/mastodon_api/views/filter_view.ex
new file mode 100644
index 000000000..6bd687d46
--- /dev/null
+++ b/lib/pleroma/web/mastodon_api/views/filter_view.ex
@@ -0,0 +1,27 @@
+defmodule Pleroma.Web.MastodonAPI.FilterView do
+ use Pleroma.Web, :view
+ alias Pleroma.Web.MastodonAPI.FilterView
+ alias Pleroma.Web.CommonAPI.Utils
+
+ def render("filters.json", %{filters: filters} = opts) do
+ render_many(filters, FilterView, "filter.json", opts)
+ end
+
+ def render("filter.json", %{filter: filter}) do
+ expires_at =
+ if filter.expires_at do
+ Utils.to_masto_date(filter.expires_at)
+ else
+ nil
+ end
+
+ %{
+ id: to_string(filter.filter_id),
+ phrase: filter.phrase,
+ context: filter.context,
+ expires_at: expires_at,
+ irreversible: filter.hide,
+ whole_word: false
+ }
+ end
+end