introduce max_id parameter in feed.atom
authorHakaba Hitoyo <example@example.com>
Fri, 9 Feb 2018 12:41:30 +0000 (21:41 +0900)
committerHakaba Hitoyo <example@example.com>
Fri, 9 Feb 2018 12:41:30 +0000 (21:41 +0900)
lib/pleroma/web/ostatus/ostatus_controller.ex

index d442d16fdaad95cd2ddb70ce23cbe5b73322e5cc..203b6e9852029aa465d0d2a429fea0ad1c29d3ab 100644 (file)
@@ -25,6 +25,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
       order_by: [desc: :id]
 
     activities = query
+    |> restrict_max(opts)    
     |> Repo.all
 
     response = user
@@ -54,6 +55,11 @@ defmodule Pleroma.Web.OStatus.OStatusController do
     end
   end
 
+  defp restrict_max(query, %{"max_id" => max_id}) do
+    from activity in query, where: activity.id < ^max_id
+  end
+  defp restrict_max(query, _), do: query
+
   def salmon_incoming(conn, _) do
     {:ok, body, _conn} = read_body(conn)
     {:ok, doc} = decode_or_retry(body)