ash_hq/lib/ash_hq_web/controllers/mailing_list_controller.ex
2022-09-01 15:19:13 -06:00

17 lines
383 B
Elixir

defmodule AshHqWeb.MailingListController do
use AshHqWeb, :controller
import Ecto.Query, only: [from: 2]
def unsubscribe(conn, %{"email" => email}) do
query =
from row in AshHq.MailingList.Email,
where: row.email == ^email
AshHq.Repo.delete_all(query)
conn
|> put_flash(:info, "You have been unsubscribed!")
|> redirect(to: "/")
end
end