From 935e544e19a2dde70a5e1cc9d8fdc1cf49da8517 Mon Sep 17 00:00:00 2001 From: eal Date: Thu, 31 May 2018 15:27:42 +0300 Subject: [PATCH] TwitterAPI: fix "Follows you" being shown for the wrong user. --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 8 ++++---- test/web/twitter_api/twitter_api_controller_test.exs | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index c2b0bb01d..320f2fcf4 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -309,18 +309,18 @@ def update_most_recent_notification(%{assigns: %{user: user}} = conn, %{"id" => end def followers(conn, params) do - with {:ok, user} <- TwitterAPI.get_user(conn.assigns.user, params), + with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params), {:ok, followers} <- User.get_followers(user) do - render(conn, UserView, "index.json", %{users: followers, for: user}) + render(conn, UserView, "index.json", %{users: followers, for: conn.assigns[:user]}) else _e -> bad_request_reply(conn, "Can't get followers") end end def friends(conn, params) do - with {:ok, user} <- TwitterAPI.get_user(conn.assigns.user, params), + with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params), {:ok, friends} <- User.get_friends(user) do - render(conn, UserView, "index.json", %{users: friends, for: user}) + render(conn, UserView, "index.json", %{users: friends, for: conn.assigns[:user]}) else _e -> bad_request_reply(conn, "Can't get friends") end diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index c2ea41aa3..03e5824a9 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -668,6 +668,7 @@ test "it returns a given user's friends with user_id", %{conn: conn} do conn = conn + |> assign(:user, user) |> get("/api/statuses/friends", %{"user_id" => user.id}) assert MapSet.equal?( @@ -689,6 +690,7 @@ test "it returns a given user's friends with screen_name", %{conn: conn} do conn = conn + |> assign(:user, user) |> get("/api/statuses/friends", %{"screen_name" => user.nickname}) assert MapSet.equal?(