Handle nil cases.
This commit is contained in:
parent
8ef58a266b
commit
867ac1e4f5
2 changed files with 7 additions and 2 deletions
|
@ -164,8 +164,8 @@ defp restrict_recent(query, _) 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
|
||||
|
|
|
@ -100,6 +100,11 @@ test "doesn't return blocked activities" 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
|
||||
|
|
Loading…
Reference in a new issue