Handle nil cases.
authorRoger Braun <roger@rogerbraun.net>
Thu, 2 Nov 2017 21:47:11 +0000 (22:47 +0100)
committerRoger Braun <roger@rogerbraun.net>
Thu, 2 Nov 2017 21:47:48 +0000 (22:47 +0100)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs

index db986f8f2f19b8176a421977f58c05a900264855..a62be2511767d3057568572db19059966cd349bf 100644 (file)
@@ -164,8 +164,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       where: activity.id > ^since
   end
 
-  defp restrict_blocked(query, %{"blocking_user" => user}) do
-    blocks = user.info["blocks"] || []
+  defp restrict_blocked(query, %{"blocking_user" => %User{info: info}}) do
+    blocks = info["blocks"] || []
     from activity in query,
       where: fragment("not (?->>'actor' = ANY(?))", activity.data, ^blocks)
   end
index 2644ad5de0275f36b9af8f37508a8dfcccf07262..a02740d5d8780b2882b646c3b4ac1e4e5ced41a0 100644 (file)
@@ -100,6 +100,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
 
     assert Enum.member?(activities, activity_two)
     assert Enum.member?(activities, activity_one)
+
+    activities = ActivityPub.fetch_activities([], %{"blocking_user" => nil})
+
+    assert Enum.member?(activities, activity_two)
+    assert Enum.member?(activities, activity_one)
   end
 
   describe "public fetch activities" do