diff --git a/lib/app_web/controllers/sent_controller.ex b/lib/app_web/controllers/sent_controller.ex index fd3f940..a61ebcf 100644 --- a/lib/app_web/controllers/sent_controller.ex +++ b/lib/app_web/controllers/sent_controller.ex @@ -130,6 +130,15 @@ defmodule AppWeb.SentController do end def pixel(conn, _params) do + # warm up the lambda function so emails are sent instantly! + payload = %{"ping" => :os.system_time(:millisecond), key: "ping"} + # IO.inspect(payload, label: "payload ping/2:151") + # see: https://github.com/dwyl/elixir-invoke-lambda-example + lambda = System.get_env("AWS_LAMBDA_FUNCTION") + ExAws.Lambda.invoke(lambda, payload, "no_context") + |> ExAws.request(region: System.get_env("AWS_REGION")) + |> IO.inspect(label: "ExAws.Lambda ping response") + conn # instruct browser not to cache the image |> put_resp_header("cache-control", "no-store, private") |> put_resp_header("pragma", "no-cache") diff --git a/mix.exs b/mix.exs index a308caf..7d02862 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule App.MixProject do def project do [ app: :app, - version: "1.0.0", + version: "1.0.1", elixir: "~> 1.10", elixirc_paths: elixirc_paths(Mix.env()), compilers: [:phoenix, :gettext] ++ Mix.compilers(),