소스 검색

Merge branch '2323-accounts-relationships-hotfix' into 'develop'

[#2323] Fixed /accounts/relationships

Closes pleroma-fe#820

See merge request pleroma/pleroma!2347
debug-remote-ip
feld 4 년 전
부모
커밋
7879369e4d
4개의 변경된 파일15개의 추가작업 그리고 8개의 파일을 삭제
  1. +5
    -3
      lib/pleroma/web/mastodon_api/views/account_view.ex
  2. +1
    -1
      lib/pleroma/web/mastodon_api/views/notification_view.ex
  3. +6
    -4
      lib/pleroma/web/mastodon_api/views/status_view.ex
  4. +3
    -0
      test/web/mastodon_api/views/account_view_test.exs

+ 5
- 3
lib/pleroma/web/mastodon_api/views/account_view.ex 파일 보기

@@ -13,16 +13,18 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
alias Pleroma.Web.MediaProxy alias Pleroma.Web.MediaProxy


def render("index.json", %{users: users} = opts) do def render("index.json", %{users: users} = opts) do
reading_user = opts[:for]

relationships_opt = relationships_opt =
cond do cond do
Map.has_key?(opts, :relationships) -> Map.has_key?(opts, :relationships) ->
opts[:relationships] opts[:relationships]


is_nil(opts[:for]) ->
is_nil(reading_user) ->
UserRelationship.view_relationships_option(nil, []) UserRelationship.view_relationships_option(nil, [])


true -> true ->
UserRelationship.view_relationships_option(opts[:for], users)
UserRelationship.view_relationships_option(reading_user, users)
end end


opts = Map.put(opts, :relationships, relationships_opt) opts = Map.put(opts, :relationships, relationships_opt)
@@ -143,7 +145,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
Map.has_key?(opts, :relationships) -> Map.has_key?(opts, :relationships) ->
opts[:relationships] opts[:relationships]


is_nil(opts[:for]) ->
is_nil(user) ->
UserRelationship.view_relationships_option(nil, []) UserRelationship.view_relationships_option(nil, [])


true -> true ->


+ 1
- 1
lib/pleroma/web/mastodon_api/views/notification_view.ex 파일 보기

@@ -36,7 +36,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationView do
Map.has_key?(opts, :relationships) -> Map.has_key?(opts, :relationships) ->
opts[:relationships] opts[:relationships]


is_nil(opts[:for]) ->
is_nil(reading_user) ->
UserRelationship.view_relationships_option(nil, []) UserRelationship.view_relationships_option(nil, [])


true -> true ->


+ 6
- 4
lib/pleroma/web/mastodon_api/views/status_view.ex 파일 보기

@@ -72,6 +72,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
end end


def render("index.json", opts) do def render("index.json", opts) do
reading_user = opts[:for]

# To do: check AdminAPIControllerTest on the reasons behind nil activities in the list # To do: check AdminAPIControllerTest on the reasons behind nil activities in the list
activities = Enum.filter(opts.activities, & &1) activities = Enum.filter(opts.activities, & &1)
replied_to_activities = get_replied_to_activities(activities) 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"]) |> Enum.map(&Object.normalize(&1).data["id"])
|> Activity.create_by_object_ap_id() |> Activity.create_by_object_ap_id()
|> Activity.with_preloaded_object(:left) |> 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() |> Repo.all()


relationships_opt = relationships_opt =
@@ -91,13 +93,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
Map.has_key?(opts, :relationships) -> Map.has_key?(opts, :relationships) ->
opts[:relationships] opts[:relationships]


is_nil(opts[:for]) ->
is_nil(reading_user) ->
UserRelationship.view_relationships_option(nil, []) UserRelationship.view_relationships_option(nil, [])


true -> true ->
actors = Enum.map(activities ++ parent_activities, &get_user(&1.data["actor"])) 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)
end end


opts = opts =


+ 3
- 0
test/web/mastodon_api/views/account_view_test.exs 파일 보기

@@ -209,6 +209,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
relationships_opt = UserRelationship.view_relationships_option(user, [other_user]) relationships_opt = UserRelationship.view_relationships_option(user, [other_user])
opts = Map.put(opts, :relationships, relationships_opt) opts = Map.put(opts, :relationships, relationships_opt)
assert expected_result == AccountView.render("relationship.json", opts) assert expected_result == AccountView.render("relationship.json", opts)

assert [expected_result] ==
AccountView.render("relationships.json", %{user: user, targets: [other_user]})
end end


@blank_response %{ @blank_response %{


불러오는 중...
취소
저장