Merge branch 'fix/twitterapi-incorrect-follows-you' into 'develop'

TwitterAPI: fix "Follows you" being shown for the wrong user.

Closes pleroma-fe#89

See merge request pleroma/pleroma!185
This commit is contained in:
lambda 2018-06-01 08:51:04 +00:00
commit 98b8f08783
2 changed files with 6 additions and 4 deletions

View File

@ -309,18 +309,18 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
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

View File

@ -668,6 +668,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
conn =
conn
|> assign(:user, user)
|> get("/api/statuses/friends", %{"user_id" => user.id})
assert MapSet.equal?(
@ -689,6 +690,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
conn =
conn
|> assign(:user, user)
|> get("/api/statuses/friends", %{"screen_name" => user.nickname})
assert MapSet.equal?(