diff options
author | kaniini <nenolod@gmail.com> | 2018-09-03 12:33:36 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2018-09-03 12:33:36 +0000 |
commit | 1c9e539b47ff594d75c9548a04e64cb0c61cff8c (patch) | |
tree | 26936ac9208ea802e17c78e31689480ff004cd3f /lib/pleroma/web/mastodon_api/views | |
parent | 8fdddc255ce4fea3060904d27634022718597133 (diff) | |
parent | 6973b77e9462475361772907ddd690a960041b64 (diff) | |
download | pleroma-1c9e539b47ff594d75c9548a04e64cb0c61cff8c.tar.gz |
Merge branch 'feature/mastodon_api_2.4.x' into 'develop'
Add/Fix Mastodon endpoints for 2.4.3 compatibility
See merge request pleroma/pleroma!266
Diffstat (limited to 'lib/pleroma/web/mastodon_api/views')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/account_view.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/filter_view.ex | 27 |
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 |