Fix bug when no posts are in the db.
authorRoger Braun <roger@rogerbraun.net>
Sun, 5 Nov 2017 11:05:25 +0000 (12:05 +0100)
committerRoger Braun <roger@rogerbraun.net>
Sun, 5 Nov 2017 11:11:59 +0000 (12:11 +0100)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs

index 71e52cb4628fb40e8bf1e1e33abc2b42801d673c..d4eb503234cf86105e34e25f517bb5db1db21610 100644 (file)
@@ -157,7 +157,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
 
   # Only search through last 100_000 activities by default
   defp restrict_recent(query, _) do
-    since = Repo.aggregate(Activity, :max, :id) - 100_000
+    since = (Repo.aggregate(Activity, :max, :id) || 0) - 100_000
 
     from activity in query,
       where: activity.id > ^since
index a088e97be36318c3bd30fccd5f0e6f88645bfe3c..48597f5fbcd55e834beb45916f1e0fb153c0f410 100644 (file)
@@ -82,6 +82,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
 
   describe "public fetch activities" do
     test "retrieves public activities" do
+      activities = ActivityPub.fetch_public_activities
+
       %{public: public} = ActivityBuilder.public_and_non_public
 
       activities = ActivityPub.fetch_public_activities