projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Scrape instance nodeinfo (#251)
[akkoma]
/
lib
/
pleroma
/
web
/
mastodon_api
/
views
/
account_view.ex
diff --git
a/lib/pleroma/web/mastodon_api/views/account_view.ex
b/lib/pleroma/web/mastodon_api/views/account_view.ex
index 4b15b163582b824074c53d9a5cabac21dc9716fd..cbb57aee663219e475ccaaeeeac48bd4cc97fedf 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/
lib/pleroma/web/mastodon_api/views/account_view.ex
@@
-186,6
+186,16
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
render_many(targets, AccountView, "relationship.json", render_opts)
end
render_many(targets, AccountView, "relationship.json", render_opts)
end
+ def render("instance.json", %{instance: %Pleroma.Instances.Instance{} = instance}) do
+ %{
+ name: instance.host,
+ favicon: instance.favicon |> MediaProxy.url(),
+ nodeinfo: instance.nodeinfo
+ }
+ end
+
+ def render("instance.json", _), do: nil
+
defp do_render("show.json", %{user: user} = opts) do
user = User.sanitize_html(user, User.html_filter_policy(opts[:for]))
display_name = user.name || user.nickname
defp do_render("show.json", %{user: user} = opts) do
user = User.sanitize_html(user, User.html_filter_policy(opts[:for]))
display_name = user.name || user.nickname
@@
-230,16
+240,20
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
%{}
end
%{}
end
- favicon =
- if Pleroma.Config.get([:instances_favicons, :enabled]) do
- user
- |> Map.get(:ap_id, "")
- |> URI.parse()
- |> URI.merge("/")
- |> Pleroma.Instances.Instance.get_or_update_favicon()
- |> MediaProxy.url()
+ instance =
+ with {:ok, instance} <- Pleroma.Instances.Instance.get_cached_by_url(user.ap_id) do
+ instance
else
else
+ _ ->
+ nil
+ end
+
+ favicon =
+ if is_nil(instance) do
nil
nil
+ else
+ instance.favicon
+ |> MediaProxy.url()
end
%{
end
%{
@@
-271,7
+285,9
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
}
},
last_status_at: user.last_status_at,
}
},
last_status_at: user.last_status_at,
-
+ akkoma: %{
+ instance: render("instance.json", %{instance: instance})
+ },
# Pleroma extensions
# Note: it's insecure to output :email but fully-qualified nickname may serve as safe stub
fqn: User.full_nickname(user),
# Pleroma extensions
# Note: it's insecure to output :email but fully-qualified nickname may serve as safe stub
fqn: User.full_nickname(user),
@@
-289,7
+305,6
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
relationship: relationship,
skip_thread_containment: user.skip_thread_containment,
background_image: image_url(user.background) |> MediaProxy.url(),
relationship: relationship,
skip_thread_containment: user.skip_thread_containment,
background_image: image_url(user.background) |> MediaProxy.url(),
- accepts_chat_messages: user.accepts_chat_messages,
favicon: favicon
}
}
favicon: favicon
}
}
@@
-297,7
+312,6
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
|> maybe_put_settings(user, opts[:for], opts)
|> maybe_put_notification_settings(user, opts[:for])
|> maybe_put_settings_store(user, opts[:for], opts)
|> maybe_put_settings(user, opts[:for], opts)
|> maybe_put_notification_settings(user, opts[:for])
|> maybe_put_settings_store(user, opts[:for], opts)
- |> maybe_put_chat_token(user, opts[:for], opts)
|> maybe_put_activation_status(user, opts[:for])
|> maybe_put_follow_requests_count(user, opts[:for])
|> maybe_put_allow_following_move(user, opts[:for])
|> maybe_put_activation_status(user, opts[:for])
|> maybe_put_follow_requests_count(user, opts[:for])
|> maybe_put_allow_following_move(user, opts[:for])
@@
-350,15
+364,6
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
defp maybe_put_settings_store(data, _, _, _), do: data
defp maybe_put_settings_store(data, _, _, _), do: data
- defp maybe_put_chat_token(data, %User{id: id}, %User{id: id}, %{
- with_chat_token: token
- }) do
- data
- |> Kernel.put_in([:pleroma, :chat_token], token)
- end
-
- defp maybe_put_chat_token(data, _, _, _), do: data
-
defp maybe_put_role(data, %User{show_role: true} = user, _) do
data
|> Kernel.put_in([:pleroma, :is_admin], user.is_admin)
defp maybe_put_role(data, %User{show_role: true} = user, _) do
data
|> Kernel.put_in([:pleroma, :is_admin], user.is_admin)