Merge remote-tracking branch 'remotes/origin/2323-accounts-relationships-hotfix' into output-of-relationships-in-statuses

# Conflicts:
#	lib/pleroma/web/mastodon_api/views/account_view.ex
#	lib/pleroma/web/mastodon_api/views/status_view.ex
This commit is contained in:
Ivan Tashkinov 2020-04-02 19:38:39 +03:00
commit 3fa51f7272
49 changed files with 51 additions and 44 deletions

View file

@ -13,17 +13,19 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
alias Pleroma.Web.MediaProxy
def render("index.json", %{users: users} = opts) do
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(opts[:for]) ->
is_nil(reading_user) ->
UserRelationship.view_relationships_option(nil, [])
true ->
UserRelationship.view_relationships_option(opts[:for], users)
UserRelationship.view_relationships_option(reading_user, users)
end
opts = Map.put(opts, :relationships, relationships_opt)
@ -144,7 +146,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
Map.has_key?(opts, :relationships) ->
opts[:relationships]
is_nil(opts[:for]) ->
is_nil(user) ->
UserRelationship.view_relationships_option(nil, [])
true ->

View file

@ -36,7 +36,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
Map.has_key?(opts, :relationships) ->
opts[:relationships]
is_nil(opts[:for]) ->
is_nil(reading_user) ->
UserRelationship.view_relationships_option(nil, [])
true ->

View file

@ -72,6 +72,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
end
def render("index.json", opts) do
reading_user = opts[:for]
# To do: check AdminAPIControllerTest on the reasons behind nil activities in the list
activities = Enum.filter(opts.activities, & &1)
replied_to_activities = get_replied_to_activities(activities)
@ -82,8 +84,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|> Enum.map(&Object.normalize(&1).data["id"])
|> Activity.create_by_object_ap_id()
|> Activity.with_preloaded_object(:left)
|> Activity.with_preloaded_bookmark(opts[:for])
|> Activity.with_set_thread_muted_field(opts[:for])
|> Activity.with_preloaded_bookmark(reading_user)
|> Activity.with_set_thread_muted_field(reading_user)
|> Repo.all()
relationships_opt =
@ -91,13 +93,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
Map.has_key?(opts, :relationships) ->
opts[:relationships]
is_nil(opts[:for]) ->
is_nil(reading_user) ->
UserRelationship.view_relationships_option(nil, [])
true ->
actors = Enum.map(activities ++ parent_activities, &get_user(&1.data["actor"]))
UserRelationship.view_relationships_option(opts[:for], actors,
UserRelationship.view_relationships_option(reading_user, actors,
source_mutes_only: opts[:skip_relationships]
)
end