From a99e156f2c0e3d2e5b5dec167efb29be1e429542 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 9 Jan 2019 18:17:23 +0100 Subject: [PATCH] Add integer casts. --- lib/pleroma/web/twitter_api/twitter_api_controller.ex | 4 ++-- test/web/twitter_api/twitter_api_controller_test.exs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 0653acebe..a44c8c50a 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -472,7 +472,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def followers(%{assigns: %{user: for_user}} = conn, params) do - page = params["page"] || 1 + {:ok, page} = Ecto.Type.cast(:integer, params["page"] || 1) with {:ok, user} <- TwitterAPI.get_user(for_user, params), {:ok, followers} <- User.get_followers(user, page) do @@ -492,7 +492,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do end def friends(%{assigns: %{user: for_user}} = conn, params) do - page = params["page"] || 1 + {:ok, page} = Ecto.Type.cast(:integer, params["page"] || 1) with {:ok, user} <- TwitterAPI.get_user(conn.assigns[:user], params), {:ok, friends} <- User.get_friends(user, page) do diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 3d355a087..1eddffec3 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -1101,7 +1101,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do res_conn = conn |> assign(:user, user) - |> get("/api/statuses/followers", %{page: 2}) + |> get("/api/statuses/followers?page=2") result = json_response(res_conn, 200) assert length(result) == 1 -- 2.45.2