From e1a547d7d3913974e1049c5dc60d46812c8abf3f Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 11 Jan 2021 15:30:40 +0100 Subject: [PATCH] ChatMessages: Fix pagination headers. They used to contain the path parameter `id` as query param, which would break the link. --- lib/pleroma/web/controller_helper.ex | 2 +- .../web/pleroma_api/controllers/chat_controller_test.exs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/controller_helper.ex b/lib/pleroma/web/controller_helper.ex index 69188a882..2df44309c 100644 --- a/lib/pleroma/web/controller_helper.ex +++ b/lib/pleroma/web/controller_helper.ex @@ -67,7 +67,7 @@ def add_link_headers(conn, entries, extra_params) 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) diff --git a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs index 24efeeb73..d0b520fbc 100644 --- a/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs +++ b/test/pleroma/web/pleroma_api/controllers/chat_controller_test.exs @@ -211,12 +211,12 @@ test "it paginates", %{conn: conn, user: user} 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 @@ test "it paginates", %{conn: conn, user: user} 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