aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-11-02 22:47:11 +0100
committerRoger Braun <roger@rogerbraun.net>2017-11-02 22:47:48 +0100
commit867ac1e4f5b1a5b994b57a73bed36710100f9cf8 (patch)
tree92a8ae9553bcf28d4bb10e5d4af473526cc27158
parent8ef58a266b6c73ac2ec49873d48fda82315c63fd (diff)
downloadpleroma-867ac1e4f5b1a5b994b57a73bed36710100f9cf8.tar.gz
Handle nil cases.
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex4
-rw-r--r--test/web/activity_pub/activity_pub_test.exs5
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index db986f8f2..a62be2511 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -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
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index 2644ad5de..a02740d5d 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -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