mirror of
https://github.com/plausible/analytics.git
synced 2024-12-24 01:54:34 +03:00
parent
91f670c85a
commit
4d97583331
@ -19,7 +19,7 @@ defmodule PlausibleWeb.InvitationController do
|
||||
if invitation.role == :owner do
|
||||
Multi.new()
|
||||
|> downgrade_previous_owner(invitation.site)
|
||||
|> end_trial_of_new_owner(user)
|
||||
|> maybe_end_trial_of_new_owner(user)
|
||||
else
|
||||
Multi.new()
|
||||
end
|
||||
@ -64,6 +64,12 @@ defmodule PlausibleWeb.InvitationController do
|
||||
Multi.update_all(multi, :prev_owner, prev_owner, set: [role: :admin])
|
||||
end
|
||||
|
||||
defp maybe_end_trial_of_new_owner(multi, new_owner) do
|
||||
if !Application.get_env(:plausible, :is_selfhost) do
|
||||
end_trial_of_new_owner(multi, new_owner)
|
||||
end
|
||||
end
|
||||
|
||||
defp end_trial_of_new_owner(multi, new_owner) do
|
||||
if Plausible.Billing.on_trial?(new_owner) || is_nil(new_owner.trial_expiry_date) do
|
||||
Ecto.Multi.update(multi, :user, Plausible.Auth.User.end_trial(new_owner))
|
||||
@ -87,22 +93,22 @@ defmodule PlausibleWeb.InvitationController do
|
||||
|
||||
defp notify_invitation_accepted(%Invitation{role: :owner} = invitation) do
|
||||
PlausibleWeb.Email.ownership_transfer_accepted(invitation)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
|
||||
defp notify_invitation_accepted(invitation) do
|
||||
PlausibleWeb.Email.invitation_accepted(invitation)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
|
||||
defp notify_invitation_rejected(%Invitation{role: :owner} = invitation) do
|
||||
PlausibleWeb.Email.ownership_transfer_rejected(invitation)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
|
||||
defp notify_invitation_rejected(invitation) do
|
||||
PlausibleWeb.Email.invitation_rejected(invitation)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
|
||||
def remove_invitation(conn, %{"invitation_id" => invitation_id}) do
|
||||
|
@ -93,7 +93,7 @@ defmodule PlausibleWeb.Site.MembershipController do
|
||||
|> Repo.preload([:site, :inviter])
|
||||
|
||||
PlausibleWeb.Email.ownership_transfer_request(invitation, user)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
|
||||
conn
|
||||
|> put_flash(:success, "Site transfer request has been sent to #{email}")
|
||||
|
@ -40,11 +40,11 @@ defmodule Plausible.Workers.NotifyAnnualRenewal do
|
||||
case user.subscription.status do
|
||||
"active" ->
|
||||
template = PlausibleWeb.Email.yearly_renewal_notification(user)
|
||||
Plausible.Mailer.send_email(template)
|
||||
Plausible.Mailer.send_email_safe(template)
|
||||
|
||||
"deleted" ->
|
||||
template = PlausibleWeb.Email.yearly_expiration_notification(user)
|
||||
Plausible.Mailer.send_email(template)
|
||||
Plausible.Mailer.send_email_safe(template)
|
||||
|
||||
_ ->
|
||||
Sentry.capture_message("Invalid subscription for renewal", user: user)
|
||||
|
@ -79,10 +79,6 @@ defmodule Plausible.Workers.SendEmailReport do
|
||||
name: name
|
||||
)
|
||||
|
||||
try do
|
||||
Plausible.Mailer.send_email(template)
|
||||
rescue
|
||||
_ -> nil
|
||||
end
|
||||
Plausible.Mailer.send_email_safe(template)
|
||||
end
|
||||
end
|
||||
|
@ -76,7 +76,7 @@ defmodule Plausible.Workers.SendSiteSetupEmails do
|
||||
|
||||
defp send_create_site_email(user) do
|
||||
PlausibleWeb.Email.create_site_email(user)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
|
||||
Repo.insert_all("create_site_emails", [
|
||||
%{
|
||||
@ -88,7 +88,7 @@ defmodule Plausible.Workers.SendSiteSetupEmails do
|
||||
|
||||
defp send_setup_success_email(user, site) do
|
||||
PlausibleWeb.Email.site_setup_success(user, site)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
|
||||
Repo.insert_all("setup_success_emails", [
|
||||
%{
|
||||
@ -100,7 +100,7 @@ defmodule Plausible.Workers.SendSiteSetupEmails do
|
||||
|
||||
defp send_setup_help_email(user, site) do
|
||||
PlausibleWeb.Email.site_setup_help(user, site)
|
||||
|> Plausible.Mailer.send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
|
||||
Repo.insert_all("setup_help_emails", [
|
||||
%{
|
||||
|
@ -50,33 +50,25 @@ defmodule Plausible.Workers.SendTrialNotifications do
|
||||
|
||||
defp send_one_week_reminder(user) do
|
||||
PlausibleWeb.Email.trial_one_week_reminder(user)
|
||||
|> send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
|
||||
defp send_tomorrow_reminder(user) do
|
||||
usage = Plausible.Billing.usage_breakdown(user)
|
||||
|
||||
PlausibleWeb.Email.trial_upgrade_email(user, "tomorrow", usage)
|
||||
|> send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
|
||||
defp send_today_reminder(user) do
|
||||
usage = Plausible.Billing.usage_breakdown(user)
|
||||
|
||||
PlausibleWeb.Email.trial_upgrade_email(user, "today", usage)
|
||||
|> send_email()
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
|
||||
defp send_over_reminder(user) do
|
||||
PlausibleWeb.Email.trial_over_email(user)
|
||||
|> send_email()
|
||||
end
|
||||
|
||||
defp send_email(email) do
|
||||
try do
|
||||
Plausible.Mailer.send_email(email)
|
||||
rescue
|
||||
_ -> nil
|
||||
end
|
||||
|> Plausible.Mailer.send_email_safe()
|
||||
end
|
||||
end
|
||||
|
@ -58,10 +58,6 @@ defmodule Plausible.Workers.SpikeNotifier do
|
||||
dashboard_link
|
||||
)
|
||||
|
||||
try do
|
||||
Plausible.Mailer.send_email(template)
|
||||
rescue
|
||||
_ -> nil
|
||||
end
|
||||
Plausible.Mailer.send_email_safe(template)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user