Add integer casts.
authorlain <lain@soykaf.club>
Wed, 9 Jan 2019 17:17:23 +0000 (18:17 +0100)
committerlain <lain@soykaf.club>
Wed, 9 Jan 2019 17:17:23 +0000 (18:17 +0100)
lib/pleroma/web/twitter_api/twitter_api_controller.ex
test/web/twitter_api/twitter_api_controller_test.exs

index 0653acebec73999ca7af55045cb3799b69b57399..a44c8c50a3db3b19c06f29e938eeef75d0e0ee18 100644 (file)
@@ -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
index 3d355a08743d070ec259311bd234f6489deb64be..1eddffec3a30d713b5d5ddc22eaa92a481fcf830 100644 (file)
@@ -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