fix `order by` for fetch_favorites
authorMaksim Pechnikov <parallel588@gmail.com>
Mon, 18 Nov 2019 18:34:54 +0000 (21:34 +0300)
committerMaksim Pechnikov <parallel588@gmail.com>
Mon, 18 Nov 2019 18:34:54 +0000 (21:34 +0300)
lib/pleroma/pagination.ex
lib/pleroma/web/activity_pub/activity_pub.ex

index 243f1a3295c37b48bae595388734cc6090f84e89..6321c26007582d47c539297921ce5505e2a12a90 100644 (file)
@@ -78,7 +78,8 @@ defmodule Pleroma.Pagination do
       since_id: :string,
       max_id: :string,
       offset: :integer,
-      limit: :integer
+      limit: :integer,
+      skip_order: :boolean
     }
 
     params =
@@ -103,6 +104,8 @@ defmodule Pleroma.Pagination do
     where(query, [{q, table_position(query, table_binding)}], q.id < ^max_id)
   end
 
+  defp restrict(query, :order, %{skip_order: true}, _), do: query
+
   defp restrict(query, :order, %{min_id: _}, table_binding) do
     order_by(
       query,
index e452278f001941070fc2615cfd0e421013708827..f1ff0ee0d5107c6c62e098c5dcaa057569bcfb9a 100644 (file)
@@ -1067,7 +1067,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     |> Object.with_joined_activity()
     |> select([_like, object, activity], %{activity | object: object})
     |> order_by([like, _, _], desc: like.updated_at)
-    |> Pagination.fetch_paginated(params, pagination, :object_activity)
+    |> Pagination.fetch_paginated(
+      Map.merge(params, %{"skip_order" => true}),
+      pagination,
+      :object_activity
+    )
   end
 
   defp maybe_update_cc(activities, list_memberships, %User{ap_id: user_ap_id})