mirror of
https://github.com/plausible/analytics.git
synced 2024-11-28 13:02:53 +03:00
c96f364ad8
* Add and remove recipients for email reports * Remove unused google_settings controller action * Background job sends email reports to multiple recipients * Add a way to unsubscribe for recipients who cannot log in * Fix view on plausible link * Include bounce rate in email report
26 lines
894 B
Elixir
26 lines
894 B
Elixir
defmodule PlausibleWeb.UnsubscribeController do
|
|
use PlausibleWeb, :controller
|
|
use Plausible.Repo
|
|
alias Plausible.Site.{WeeklyReport, MonthlyReport}
|
|
|
|
def weekly_report(conn, %{"website" => website, "email" => email}) do
|
|
site = Repo.get_by(Plausible.Site, domain: website)
|
|
|
|
Repo.get_by(WeeklyReport, site_id: site.id)
|
|
|> WeeklyReport.remove_recipient(email)
|
|
|> Repo.update!
|
|
|
|
render(conn, "success.html", interval: "weekly", site: website, layout: {PlausibleWeb.LayoutView, "focus.html"})
|
|
end
|
|
|
|
def monthly_report(conn, %{"website" => website, "email" => email}) do
|
|
site = Repo.get_by(Plausible.Site, domain: website)
|
|
|
|
Repo.get_by(MonthlyReport, site_id: site.id)
|
|
|> MonthlyReport.remove_recipient(email)
|
|
|> Repo.update!
|
|
|
|
render(conn, "success.html", interval: "monthly", site: website, layout: {PlausibleWeb.LayoutView, "focus.html"})
|
|
end
|
|
end
|