2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-20 11:57:51 +01:00
|
|
|
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer
|
2018-05-23 11:27:33 +02:00
|
|
|
class UserMailer < ApplicationMailer
|
2020-02-11 18:17:09 +01:00
|
|
|
helper MailerHelper
|
|
|
|
|
2018-05-23 11:27:33 +02:00
|
|
|
layout 'mailers/layout'
|
|
|
|
|
2020-02-11 18:17:09 +01:00
|
|
|
def new_account_warning(user, procedure = nil)
|
2018-05-23 11:27:33 +02:00
|
|
|
@user = user
|
2018-05-31 16:41:58 +02:00
|
|
|
@subject = "Demande de création de compte"
|
2020-02-11 18:17:09 +01:00
|
|
|
@procedure = procedure
|
2018-05-31 23:58:10 +02:00
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_user(user)
|
|
|
|
|
2020-02-11 18:17:09 +01:00
|
|
|
mail(to: user.email, subject: @subject, procedure: @procedure)
|
2018-05-23 11:27:33 +02:00
|
|
|
end
|
2019-07-09 17:08:27 +02:00
|
|
|
|
2021-10-26 13:36:14 +02:00
|
|
|
def ask_for_merge(user, requested_email)
|
2019-07-09 17:08:27 +02:00
|
|
|
@user = user
|
|
|
|
@requested_email = requested_email
|
2021-10-26 13:36:14 +02:00
|
|
|
@subject = "Fusion de compte"
|
2019-07-09 17:08:27 +02:00
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_email(requested_email)
|
|
|
|
|
2019-07-09 17:08:27 +02:00
|
|
|
mail(to: requested_email, subject: @subject)
|
|
|
|
end
|
2019-08-07 15:52:38 +02:00
|
|
|
|
2024-01-11 11:31:36 +01:00
|
|
|
def france_connect_merge_confirmation(email, email_merge_token, email_merge_token_created_at)
|
|
|
|
@email_merge_token = email_merge_token
|
|
|
|
@email_merge_token_created_at = email_merge_token_created_at
|
2021-11-17 16:21:55 +01:00
|
|
|
@subject = "Veuillez confirmer la fusion de compte"
|
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_email(email)
|
|
|
|
|
2021-11-17 16:21:55 +01:00
|
|
|
mail(to: email, subject: @subject)
|
|
|
|
end
|
|
|
|
|
2019-08-07 15:52:38 +02:00
|
|
|
def invite_instructeur(user, reset_password_token)
|
|
|
|
@reset_password_token = reset_password_token
|
|
|
|
@user = user
|
|
|
|
subject = "Activez votre compte instructeur"
|
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_user(user)
|
|
|
|
|
2024-05-29 12:24:05 +02:00
|
|
|
bypass_unverified_mail_protection!
|
|
|
|
|
2023-08-25 22:53:30 +02:00
|
|
|
mail(to: user.email,
|
|
|
|
subject: subject,
|
2024-03-26 18:58:13 +01:00
|
|
|
reply_to: Current.contact_email)
|
2023-08-25 22:53:30 +02:00
|
|
|
end
|
|
|
|
|
2024-07-10 10:57:26 +02:00
|
|
|
def invite_tiers(user, token, dossier)
|
|
|
|
@token = token
|
|
|
|
@user = user
|
|
|
|
@dossier = dossier
|
|
|
|
subject = "Vérification de votre mail"
|
|
|
|
|
|
|
|
configure_defaults_for_user(user)
|
|
|
|
|
|
|
|
bypass_unverified_mail_protection!
|
|
|
|
|
|
|
|
mail(to: user.email,
|
|
|
|
subject: subject,
|
|
|
|
reply_to: Current.contact_email)
|
|
|
|
end
|
|
|
|
|
2023-09-04 12:07:04 +02:00
|
|
|
def invite_gestionnaire(user, reset_password_token, groupe_gestionnaire)
|
2023-08-25 22:53:30 +02:00
|
|
|
@reset_password_token = reset_password_token
|
|
|
|
@user = user
|
2023-09-04 12:07:04 +02:00
|
|
|
@groupe_gestionnaire = groupe_gestionnaire
|
2023-08-25 22:53:30 +02:00
|
|
|
subject = "Activez votre compte gestionnaire"
|
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_user(user)
|
|
|
|
|
2024-05-29 12:24:05 +02:00
|
|
|
bypass_unverified_mail_protection!
|
|
|
|
|
2019-08-07 15:52:38 +02:00
|
|
|
mail(to: user.email,
|
|
|
|
subject: subject,
|
2024-03-26 18:58:13 +01:00
|
|
|
reply_to: Current.contact_email)
|
2019-08-07 15:52:38 +02:00
|
|
|
end
|
2022-06-23 13:51:58 +02:00
|
|
|
|
|
|
|
def send_archive(administrateur_or_instructeur, procedure, archive)
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_user(administrateur_or_instructeur.user)
|
|
|
|
|
2022-06-23 13:51:58 +02:00
|
|
|
@archive = archive
|
|
|
|
@procedure = procedure
|
|
|
|
@archive_url = case administrateur_or_instructeur
|
|
|
|
when Instructeur then instructeur_archives_url(@procedure)
|
|
|
|
when Administrateur then admin_procedure_archives_url(@procedure)
|
|
|
|
else raise ArgumentError("send_archive expect either an Instructeur or an Administrateur")
|
|
|
|
end
|
|
|
|
@procedure_url = case administrateur_or_instructeur
|
|
|
|
when Instructeur then instructeur_procedure_url(@procedure.id)
|
|
|
|
when Administrateur then admin_procedure_url(@procedure)
|
|
|
|
else raise ArgumentError("send_archive expect either an Instructeur or an Administrateur")
|
|
|
|
end
|
|
|
|
subject = "Votre archive est disponible"
|
|
|
|
|
|
|
|
mail(to: administrateur_or_instructeur.email, subject: subject)
|
|
|
|
end
|
2023-01-23 14:56:05 +01:00
|
|
|
|
2023-11-03 10:39:41 +01:00
|
|
|
def notify_inactive_close_to_deletion(user)
|
|
|
|
@user = user
|
2023-11-07 07:47:40 +01:00
|
|
|
@subject = "Votre compte sera supprimé dans #{Expired::REMAINING_WEEKS_BEFORE_EXPIRATION} semaines"
|
2023-11-03 10:39:41 +01:00
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_user(user)
|
|
|
|
|
2023-11-03 10:39:41 +01:00
|
|
|
mail(to: user.email, subject: @subject)
|
|
|
|
end
|
|
|
|
|
2024-02-15 11:09:00 +01:00
|
|
|
def notify_after_closing(user, content, procedure = nil)
|
|
|
|
@user = user
|
2024-07-01 10:25:49 +02:00
|
|
|
@subject = "Clôture d'une démarche sur #{Current.application_name}"
|
2024-02-15 11:09:00 +01:00
|
|
|
@procedure = procedure
|
|
|
|
@content = content
|
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
configure_defaults_for_user(user)
|
|
|
|
|
2024-02-15 11:09:00 +01:00
|
|
|
mail(to: user.email, subject: @subject, content: @content, procedure: @procedure)
|
|
|
|
end
|
|
|
|
|
2023-10-18 07:10:26 +02:00
|
|
|
def self.critical_email?(action_name)
|
2023-11-03 10:39:41 +01:00
|
|
|
[
|
|
|
|
'france_connect_merge_confirmation',
|
|
|
|
"new_account_warning",
|
|
|
|
"ask_for_merge",
|
|
|
|
"invite_instructeur"
|
|
|
|
].include?(action_name)
|
2023-01-23 14:56:05 +01:00
|
|
|
end
|
2018-05-23 11:27:33 +02:00
|
|
|
end
|