aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-05-09 19:03:07 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-05-09 19:03:07 +0300
commitac4250a18c27477974a643a730ef89d6c66220f9 (patch)
tree3249433716425a4fdaf48ccb3ab78ae312d50f31 /lib
parent14a49a04837b0dc5a0d72dd7c5b4dfa482801e7c (diff)
downloadpleroma-ac4250a18c27477974a643a730ef89d6c66220f9.tar.gz
[#2456] Clarified `skip_relationships` option (and its default of `false`) for MastodonAPI.AccountView.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex12
1 files 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 @@ defmodule Pleroma.Web.MastodonAPI.AccountView 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