Merge branch 'csv-export' into 'develop'

Add option to return all friends in twitter api.

Closes #602

See merge request pleroma/pleroma!833
This commit is contained in:
kaniini 2019-02-18 03:59:46 +00:00
commit 3f38a05571
2 changed files with 12 additions and 1 deletions

View File

@ -524,6 +524,9 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
def friends(%{assigns: %{user: for_user}} = conn, params) do def friends(%{assigns: %{user: for_user}} = conn, params) do
{:ok, page} = Ecto.Type.cast(:integer, params["page"] || 1) {:ok, page} = Ecto.Type.cast(:integer, params["page"] || 1)
{:ok, export} = Ecto.Type.cast(:boolean, params["all"] || false)
page = if export, do: nil, else: page
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, page) do {:ok, friends} <- User.get_friends(user, page) do

View File

@ -1218,7 +1218,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
assert Enum.sort(expected) == Enum.sort(result) assert Enum.sort(expected) == Enum.sort(result)
end end
test "it returns 20 friends per page", %{conn: conn} do test "it returns 20 friends per page, except if 'export' is set to true", %{conn: conn} do
user = insert(:user) user = insert(:user)
followeds = insert_list(21, :user) followeds = insert_list(21, :user)
@ -1242,6 +1242,14 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
result = json_response(res_conn, 200) result = json_response(res_conn, 200)
assert length(result) == 1 assert length(result) == 1
res_conn =
conn
|> assign(:user, user)
|> get("/api/statuses/friends", %{all: true})
result = json_response(res_conn, 200)
assert length(result) == 21
end end
test "it returns a given user's friends with user_id", %{conn: conn} do test "it returns a given user's friends with user_id", %{conn: conn} do