activitypub: add restrict_limit
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 22 Mar 2018 04:47:18 +0000 (04:47 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Thu, 22 Mar 2018 05:26:47 +0000 (00:26 -0500)
lib/pleroma/web/activity_pub/activity_pub.ex

index 7b1207ce274876f8157e6629f446efd63c8a07f8..bdc1b5df73b7f37b5a0dc726cf7d5751bfc2bb4e 100644 (file)
@@ -185,6 +185,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       or_where: activity.actor == ^user.ap_id
   end
 
+  defp restrict_limit(query, %{"limit" => limit}) do
+    from activity in query,
+      limit: ^limit
+  end
+  defp restrict_limit(query, _), do: query
+
   defp restrict_local(query, %{"local_only" => true}) do
     from activity in query, where: activity.local == true
   end
@@ -248,6 +254,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     |> restrict_tag(opts)
     |> restrict_since(opts)
     |> restrict_local(opts)
+    |> restrict_limit(opts)
     |> restrict_max(opts)
     |> restrict_actor(opts)
     |> restrict_type(opts)