Fix notifications query not working for those without
referenced_activity
This commit is contained in:
parent
596698a634
commit
8b18d10b0a
|
@ -123,13 +123,24 @@ defmodule Clacks.Timeline do
|
||||||
referenced_object: referenced_object,
|
referenced_object: referenced_object,
|
||||||
activity_actor: activity_actor
|
activity_actor: activity_actor
|
||||||
],
|
],
|
||||||
|
{n, activity, object, activity_actor, referenced_activity, referenced_object}
|
||||||
|
)
|
||||||
|
|> Repo.all()
|
||||||
|
|> Enum.map(fn {n, activity, object, activity_actor, referenced_activity, referenced_object} ->
|
||||||
|
# unfortunately we can't use the select to set the associations because we need to handle the possibility of referenced_activity being nil
|
||||||
|
referenced_activity =
|
||||||
|
case referenced_activity do
|
||||||
|
nil -> nil
|
||||||
|
a -> %Activity{a | object: referenced_object}
|
||||||
|
end
|
||||||
|
|
||||||
%Notification{
|
%Notification{
|
||||||
n
|
n
|
||||||
| activity: %Activity{activity | object: object, actor: activity_actor},
|
| activity: %Activity{activity | object: object, actor: activity_actor},
|
||||||
referenced_activity: %Activity{referenced_activity | object: referenced_object}
|
referenced_activity: referenced_activity
|
||||||
}
|
}
|
||||||
)
|
end)
|
||||||
|> Repo.all()
|
|> IO.inspect()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp restrict_to_actor(query, actor_id) do
|
defp restrict_to_actor(query, actor_id) do
|
||||||
|
|
Loading…
Reference in New Issue