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
|
where: activity.id > ^since
|
||||||
end
|
end
|
||||||
|
|
||||||
defp restrict_blocked(query, %{"blocking_user" => user}) do
|
defp restrict_blocked(query, %{"blocking_user" => %User{info: info}}) do
|
||||||
blocks = user.info["blocks"] || []
|
blocks = info["blocks"] || []
|
||||||
from activity in query,
|
from activity in query,
|
||||||
where: fragment("not (?->>'actor' = ANY(?))", activity.data, ^blocks)
|
where: fragment("not (?->>'actor' = ANY(?))", activity.data, ^blocks)
|
||||||
end
|
end
|
||||||
|
|
|
@ -100,6 +100,11 @@ test "doesn't return blocked activities" do
|
||||||
|
|
||||||
assert Enum.member?(activities, activity_two)
|
assert Enum.member?(activities, activity_two)
|
||||||
assert Enum.member?(activities, activity_one)
|
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
|
end
|
||||||
|
|
||||||
describe "public fetch activities" do
|
describe "public fetch activities" do
|
||||||
|
|
Loading…
Reference in a new issue