Fix notifications query not working for those without

referenced_activity
This commit is contained in:
Shadowfacts 2021-08-26 22:57:15 -04:00
parent 596698a634
commit 8b18d10b0a
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 14 additions and 3 deletions

View File

@ -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