aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2020-05-10 09:16:48 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2020-05-10 09:16:48 +0300
commitaee88d11be898921d79ad7f1481ab055190f4dfd (patch)
treed1b4c8b3c971233fce18755fbd4df61d172c46ef /lib
parentac4250a18c27477974a643a730ef89d6c66220f9 (diff)
downloadpleroma-aee88d11be898921d79ad7f1481ab055190f4dfd.tar.gz
[#2456] Removed support for embedded relationships in account view.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/admin_api/admin_api_controller.ex13
-rw-r--r--lib/pleroma/web/admin_api/views/account_view.ex2
-rw-r--r--lib/pleroma/web/chat_channel.ex7
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/search_controller.ex3
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex41
-rw-r--r--lib/pleroma/web/mastodon_api/views/notification_view.ex6
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex6
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex3
8 files changed, 16 insertions, 65 deletions
diff --git a/lib/pleroma/web/admin_api/admin_api_controller.ex b/lib/pleroma/web/admin_api/admin_api_controller.ex
index d2c5a6b9c..987b3bcba 100644
--- a/lib/pleroma/web/admin_api/admin_api_controller.ex
+++ b/lib/pleroma/web/admin_api/admin_api_controller.ex
@@ -22,6 +22,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
alias Pleroma.Web.ActivityPub.Pipeline
alias Pleroma.Web.ActivityPub.Relay
alias Pleroma.Web.ActivityPub.Utils
+ alias Pleroma.Web.AdminAPI
alias Pleroma.Web.AdminAPI.AccountView
alias Pleroma.Web.AdminAPI.ConfigView
alias Pleroma.Web.AdminAPI.ModerationLogView
@@ -31,7 +32,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.Endpoint
alias Pleroma.Web.MastodonAPI.AppView
- alias Pleroma.Web.MastodonAPI.StatusView
+ alias Pleroma.Web.MastodonAPI
alias Pleroma.Web.OAuth.App
alias Pleroma.Web.Router
@@ -280,7 +281,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
})
conn
- |> put_view(Pleroma.Web.AdminAPI.StatusView)
+ |> put_view(AdminAPI.StatusView)
|> render("index.json", %{activities: activities, as: :activity})
end
@@ -299,7 +300,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
})
conn
- |> put_view(StatusView)
+ |> put_view(MastodonAPI.StatusView)
|> render("index.json", %{activities: activities, as: :activity})
else
_ -> {:error, :not_found}
@@ -829,14 +830,14 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
})
conn
- |> put_view(Pleroma.Web.AdminAPI.StatusView)
+ |> put_view(AdminAPI.StatusView)
|> render("index.json", %{activities: activities, as: :activity})
end
def status_show(conn, %{"id" => id}) do
with %Activity{} = activity <- Activity.get_by_id(id) do
conn
- |> put_view(StatusView)
+ |> put_view(MastodonAPI.StatusView)
|> render("show.json", %{activity: activity})
else
_ -> errors(conn, {:error, :not_found})
@@ -856,7 +857,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
})
conn
- |> put_view(StatusView)
+ |> put_view(MastodonAPI.StatusView)
|> render("show.json", %{activity: activity})
end
end
diff --git a/lib/pleroma/web/admin_api/views/account_view.ex b/lib/pleroma/web/admin_api/views/account_view.ex
index 8471b0f09..46dadb5ee 100644
--- a/lib/pleroma/web/admin_api/views/account_view.ex
+++ b/lib/pleroma/web/admin_api/views/account_view.ex
@@ -122,7 +122,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
end
def merge_account_views(%User{} = user) do
- MastodonAPI.AccountView.render("show.json", %{user: user, skip_relationships: true})
+ MastodonAPI.AccountView.render("show.json", %{user: user})
|> Map.merge(AdminAPI.AccountView.render("show.json", %{user: user}))
end
diff --git a/lib/pleroma/web/chat_channel.ex b/lib/pleroma/web/chat_channel.ex
index 3df8dc0f1..bce27897f 100644
--- a/lib/pleroma/web/chat_channel.ex
+++ b/lib/pleroma/web/chat_channel.ex
@@ -22,12 +22,7 @@ defmodule Pleroma.Web.ChatChannel do
if String.length(text) in 1..Pleroma.Config.get([:instance, :chat_limit]) do
author = User.get_cached_by_nickname(user_name)
-
- author =
- Pleroma.Web.MastodonAPI.AccountView.render("show.json",
- user: author,
- skip_relationships: true
- )
+ author = Pleroma.Web.MastodonAPI.AccountView.render("show.json", user: author)
message = ChatChannelState.add_message(%{text: text, author: author})
diff --git a/lib/pleroma/web/mastodon_api/controllers/search_controller.ex b/lib/pleroma/web/mastodon_api/controllers/search_controller.ex
index 5d3318ce0..c30ae1c7a 100644
--- a/lib/pleroma/web/mastodon_api/controllers/search_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/search_controller.ex
@@ -86,8 +86,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
AccountView.render("index.json",
users: accounts,
for: options[:for_user],
- as: :user,
- skip_relationships: true
+ as: :user
)
end
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index c1786a322..b3a14d255 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -12,33 +12,7 @@ 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 = initialize_skip_relationships(opts)
-
- reading_user = opts[:for]
-
- relationships_opt =
- cond do
- Map.has_key?(opts, :relationships) ->
- opts[:relationships]
-
- is_nil(reading_user) || opts[:skip_relationships] ->
- UserRelationship.view_relationships_option(nil, [])
-
- true ->
- UserRelationship.view_relationships_option(reading_user, users)
- end
-
- opts = Map.put(opts, :relationships, relationships_opt)
-
users
|> render_many(AccountView, "show.json", opts)
|> Enum.filter(&Enum.any?/1)
@@ -169,8 +143,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
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
@@ -203,17 +175,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
}
end)
- relationship =
- if opts[:skip_relationships] do
- %{}
- else
- render("relationship.json", %{
- user: opts[:for],
- target: user,
- relationships: opts[:relationships]
- })
- end
-
%{
id: to_string(user.id),
username: username_from_nickname(user.nickname),
@@ -252,7 +213,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
hide_followers: user.hide_followers,
hide_follows: user.hide_follows,
hide_favorites: user.hide_favorites,
- relationship: relationship,
+ relationship: %{},
skip_thread_containment: user.skip_thread_containment,
background_image: image_url(user.background) |> MediaProxy.url()
}
diff --git a/lib/pleroma/web/mastodon_api/views/notification_view.ex b/lib/pleroma/web/mastodon_api/views/notification_view.ex
index 0349bcc83..a53218d59 100644
--- a/lib/pleroma/web/mastodon_api/views/notification_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/notification_view.ex
@@ -84,12 +84,10 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
# Note: :relationships contain user mutes (needed for :muted flag in :status)
status_render_opts = %{relationships: opts[:relationships]}
- account_render_opts = %{skip_relationships: true}
-
with %{id: _} = account <-
AccountView.render(
"show.json",
- Map.merge(account_render_opts, %{user: actor, for: reading_user})
+ %{user: actor, for: reading_user}
) do
response = %{
id: to_string(notification.id),
@@ -112,7 +110,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
put_status(response, parent_activity_fn.(), reading_user, status_render_opts)
"move" ->
- put_target(response, activity, reading_user, account_render_opts)
+ put_target(response, activity, reading_user, %{})
"pleroma:emoji_reaction" ->
response
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 8762f23fd..f7895c514 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -160,8 +160,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
account:
AccountView.render("show.json", %{
user: user,
- for: opts[:for],
- skip_relationships: true
+ for: opts[:for]
}),
in_reply_to_id: nil,
in_reply_to_account_id: nil,
@@ -327,8 +326,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
account:
AccountView.render("show.json", %{
user: user,
- for: opts[:for],
- skip_relationships: true
+ for: opts[:for]
}),
in_reply_to_id: reply_to && to_string(reply_to.id),
in_reply_to_account_id: reply_to_user && to_string(reply_to_user.id),
diff --git a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex
index b61a6791b..e834133b2 100644
--- a/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex
+++ b/lib/pleroma/web/pleroma_api/controllers/pleroma_api_controller.ex
@@ -73,8 +73,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIController do
AccountView.render("index.json", %{
users: users,
for: user,
- as: :user,
- skip_relationships: true
+ as: :user
}),
me: !!(user && user.ap_id in user_ap_ids)
}