ChatMessages: Fix pagination headers.
authorlain <lain@soykaf.club>
Mon, 11 Jan 2021 14:30:40 +0000 (15:30 +0100)
committerlain <lain@soykaf.club>
Mon, 11 Jan 2021 14:30:40 +0000 (15:30 +0100)
They used to contain the path parameter `id` as query param,
which would break the link.

lib/pleroma/web/controller_helper.ex
test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs

index 69188a882049de1af680d78bc1aebecff6319e67..2df44309cd8ef9d7de9b6f9be57a185ca908bac7 100644 (file)
@@ -67,7 +67,7 @@ defmodule Pleroma.Web.ControllerHelper do
   defp build_pagination_fields(conn, min_id, max_id, extra_params) do
     params =
       conn.params
-      |> Map.drop(Map.keys(conn.path_params))
+      |> Map.drop(Map.keys(conn.path_params) |> Enum.map(&String.to_atom/1))
       |> Map.merge(extra_params)
       |> Map.drop(@id_keys)
 
index 24efeeb73a36ef445a34ceec718fab2df7601ae5..d0b520fbc7ace55746963321f1c8fbb058d7c438 100644 (file)
@@ -211,12 +211,12 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
 
       assert String.match?(
                next,
-               ~r(#{api_endpoint}.*/messages\?id=.*&limit=\d+&max_id=.*; rel=\"next\"$)
+               ~r(#{api_endpoint}.*/messages\?limit=\d+&max_id=.*; rel=\"next\"$)
              )
 
       assert String.match?(
                prev,
-               ~r(#{api_endpoint}.*/messages\?id=.*&limit=\d+&min_id=.*; rel=\"prev\"$)
+               ~r(#{api_endpoint}.*/messages\?limit=\d+&min_id=.*; rel=\"prev\"$)
              )
 
       assert length(result) == 20
@@ -229,12 +229,12 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
 
       assert String.match?(
                next,
-               ~r(#{api_endpoint}.*/messages\?id=.*&limit=\d+&max_id=.*; rel=\"next\"$)
+               ~r(#{api_endpoint}.*/messages\?limit=\d+&max_id=.*; rel=\"next\"$)
              )
 
       assert String.match?(
                prev,
-               ~r(#{api_endpoint}.*/messages\?id=.*&limit=\d+&max_id=.*&min_id=.*; rel=\"prev\"$)
+               ~r(#{api_endpoint}.*/messages\?limit=\d+&max_id=.*&min_id=.*; rel=\"prev\"$)
              )
 
       assert length(result) == 10