From 867ac1e4f5b1a5b994b57a73bed36710100f9cf8 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 2 Nov 2017 22:47:11 +0100 Subject: [PATCH] Handle nil cases. --- lib/pleroma/web/activity_pub/activity_pub.ex | 4 ++-- test/web/activity_pub/activity_pub_test.exs | 5 +++++ 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 -- 2.45.2