alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.Web.MediaProxy
+ # Default behaviour for account view is to include embedded relationships
+ # (e.g. when accounts are rendered on their own [e.g. a list of search results], not as
+ # embedded content in notifications / statuses).
+ # This option must be explicitly set to false when rendering accounts as embedded content.
+ defp initialize_skip_relationships(opts) do
+ Map.merge(%{skip_relationships: false}, opts)
+ end
+
def render("index.json", %{users: users} = opts) do
+ opts = initialize_skip_relationships(opts)
+
reading_user = opts[:for]
- # Note: :skip_relationships option is currently intentionally not supported for accounts
relationships_opt =
cond do
Map.has_key?(opts, :relationships) ->
opts[:relationships]
- is_nil(reading_user) ->
+ is_nil(reading_user) || opts[:skip_relationships] ->
UserRelationship.view_relationships_option(nil, [])
true ->
end
defp do_render("show.json", %{user: user} = opts) do
+ opts = initialize_skip_relationships(opts)
+
user = User.sanitize_html(user, User.html_filter_policy(opts[:for]))
display_name = user.name || user.nickname