From ac4250a18c27477974a643a730ef89d6c66220f9 Mon Sep 17 00:00:00 2001 From: Ivan Tashkinov Date: Sat, 9 May 2020 19:03:07 +0300 Subject: [PATCH] [#2456] Clarified `skip_relationships` option (and its default of `false`) for MastodonAPI.AccountView. --- lib/pleroma/web/mastodon_api/views/account_view.ex | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index f0b157962..c1786a322 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -12,8 +12,16 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do 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 = Map.merge(%{skip_relationships: false}, opts) + opts = initialize_skip_relationships(opts) reading_user = opts[:for] @@ -161,7 +169,7 @@ def render("relationships.json", %{user: user, targets: targets} = opts) do end defp do_render("show.json", %{user: user} = opts) do - opts = Map.merge(%{skip_relationships: false}, opts) + opts = initialize_skip_relationships(opts) user = User.sanitize_html(user, User.html_filter_policy(opts[:for])) display_name = user.name || user.nickname