forked from AkkomaGang/akkoma
TwitterAPI: fix "Follows you" being shown for the wrong user.
This commit is contained in:
parent
196d36a7d5
commit
935e544e19
2 changed files with 6 additions and 4 deletions
|
@ -309,18 +309,18 @@ def update_most_recent_notification(%{assigns: %{user: user}} = conn, %{"id" =>
|
||||||
end
|
end
|
||||||
|
|
||||||
def followers(conn, params) do
|
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
|
{: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
|
else
|
||||||
_e -> bad_request_reply(conn, "Can't get followers")
|
_e -> bad_request_reply(conn, "Can't get followers")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def friends(conn, params) do
|
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
|
{: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
|
else
|
||||||
_e -> bad_request_reply(conn, "Can't get friends")
|
_e -> bad_request_reply(conn, "Can't get friends")
|
||||||
end
|
end
|
||||||
|
|
|
@ -668,6 +668,7 @@ test "it returns a given user's friends with user_id", %{conn: conn} do
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|> get("/api/statuses/friends", %{"user_id" => user.id})
|
|> get("/api/statuses/friends", %{"user_id" => user.id})
|
||||||
|
|
||||||
assert MapSet.equal?(
|
assert MapSet.equal?(
|
||||||
|
@ -689,6 +690,7 @@ test "it returns a given user's friends with screen_name", %{conn: conn} do
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|> get("/api/statuses/friends", %{"screen_name" => user.nickname})
|
|> get("/api/statuses/friends", %{"screen_name" => user.nickname})
|
||||||
|
|
||||||
assert MapSet.equal?(
|
assert MapSet.equal?(
|
||||||
|
|
Loading…
Reference in a new issue