Handle nil cases.

This commit is contained in:
Roger Braun 2017-11-02 22:47:11 +01:00
parent 8ef58a266b
commit 867ac1e4f5
2 changed files with 7 additions and 2 deletions

View 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

View 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