diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-14 19:34:59 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-14 19:34:59 +0300 |
| commit | 50ce8cb96b2b218751c2fc2a6b19372f51846acc (patch) | |
| tree | e2c634d2ce856062d527667d47815a05a53361c8 /lib/silmataivas/mailer.ex | |
| parent | 0ab2e5ba2b0631b28b5b1405559237b3913c878f (diff) | |
feat: rewrite in rust
Diffstat (limited to 'lib/silmataivas/mailer.ex')
| -rw-r--r-- | lib/silmataivas/mailer.ex | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/lib/silmataivas/mailer.ex b/lib/silmataivas/mailer.ex deleted file mode 100644 index 3c11436..0000000 --- a/lib/silmataivas/mailer.ex +++ /dev/null @@ -1,44 +0,0 @@ -defmodule Silmataivas.Mailer do - use Swoosh.Mailer, otp_app: :silmataivas - require Logger - - def send_alert( - email, - %{ - "main" => %{"temp" => temp}, - "wind" => %{"speed" => speed}, - "dt_txt" => time_str - } = entry - ) do - rain_mm = get_in(entry, ["rain", "3h"]) || 0.0 - wind_kmh = speed * 3.6 - - import Swoosh.Email - - body = """ - 🚨 Weather alert for your location (#{time_str}): - - 🌬️ Wind: #{Float.round(wind_kmh, 1)} km/h - 🌧️ Rain: #{rain_mm} mm - 🌡️ Temperature: #{temp} °C - - Stay safe, - — Silmätaivas - """ - - email_struct = - new() - |> to(email) - |> from({"Silmätaivas Alerts", "silmataivas@rycerz.cloud"}) - |> subject("⚠️ Weather Alert for Your Location") - |> text_body(body) - - case deliver(email_struct) do - {:ok, response} -> - Logger.info("📨 Email sent via SES: #{inspect(response)}") - - {:error, reason} -> - Logger.error("❌ Failed to send email: #{inspect(reason)}") - end - end -end |
