From 046bee34d3b19c046dba59c1d6cb08548f978859 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sun, 5 Nov 2017 12:05:25 +0100 Subject: [PATCH] Fix bug when no posts are in the db. --- lib/pleroma/web/activity_pub/activity_pub.ex | 2 +- test/web/activity_pub/activity_pub_test.exs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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