+ def create_poll_notifications(%Activity{} = activity) do
+ with %Object{data: %{"type" => "Question", "actor" => actor} = data} <-
+ Object.normalize(activity) do
+ voters =
+ case data do
+ %{"voters" => voters} when is_list(voters) -> voters
+ _ -> []
+ end
+
+ notifications =
+ Enum.map([actor | voters], fn ap_id ->
+ with %User{} = user <- User.get_by_ap_id(ap_id) do
+ create_notification(activity, user, type: "poll")
+ end
+ end)
+
+ {:ok, notifications}
+ end
+ end
+