mastodon_api_controller.ex: fallback to first for min_id
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Thu, 28 Mar 2019 16:18:44 +0000 (17:18 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Thu, 28 Mar 2019 16:23:21 +0000 (17:23 +0100)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index 5cc19e68f44dabfee31f2816c838ee0dc6982631..b2fc68707e7f3dd73a8ecae23064995bc91f03fc 100644 (file)
@@ -212,7 +212,16 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         |> Map.get("limit", "20")
         |> String.to_integer()
 
-      min_id = Enum.at(activities, limit * -1)
+      min_id =
+        if length(activities) <= limit do
+          activities
+          |> List.first()
+          |> Map.get(:id)
+        else
+          activities
+          |> Enum.at(limit * -1)
+          |> Map.get(:id)
+        end
 
       {next_url, prev_url} =
         if param do