From: Roger Braun Date: Sun, 5 Nov 2017 11:05:25 +0000 (+0100) Subject: Fix bug when no posts are in the db. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=046bee34d3b19c046dba59c1d6cb08548f978859;p=akkoma Fix bug when no posts are in the db. --- diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 71e52cb46..d4eb50323 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -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 diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index a088e97be..48597f5fb 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -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