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/avis_mailer
|
2017-05-02 15:37:06 +02:00
|
|
|
class AvisMailer < ApplicationMailer
|
2020-04-07 12:05:36 +02:00
|
|
|
helper MailerHelper
|
|
|
|
|
2018-11-23 11:04:28 +01:00
|
|
|
layout 'mailers/layout'
|
|
|
|
|
2022-06-13 13:44:06 +02:00
|
|
|
def avis_invitation(avis, targeted_user_link = nil) # ensure re-entrance if existing AvisMailer.avis_invitation in queue
|
2022-03-09 10:27:43 +01:00
|
|
|
if avis.dossier.visible_by_administration?
|
2022-06-13 13:44:06 +02:00
|
|
|
targeted_user_link = avis.targeted_user_links
|
|
|
|
.find_or_create_by(target_context: 'avis',
|
|
|
|
target_model_type: Avis.name,
|
|
|
|
target_model_id: avis.id,
|
|
|
|
user: avis.expert.user)
|
2021-04-12 10:35:52 +02:00
|
|
|
@avis = avis
|
|
|
|
email = @avis.expert&.email
|
2022-05-23 15:09:22 +02:00
|
|
|
@url = targeted_user_link_url(targeted_user_link)
|
2021-04-12 10:35:52 +02:00
|
|
|
subject = "Donnez votre avis sur le dossier nº #{@avis.dossier.id} (#{@avis.dossier.procedure.libelle})"
|
2018-05-31 23:58:10 +02:00
|
|
|
|
2021-04-12 10:35:52 +02:00
|
|
|
mail(to: email, subject: subject)
|
|
|
|
end
|
2017-05-02 15:37:06 +02:00
|
|
|
end
|
2023-10-18 07:10:26 +02:00
|
|
|
|
2024-01-03 13:23:48 +01:00
|
|
|
# i18n-tasks-use t("avis_mailer.#{action}.subject")
|
|
|
|
def notify_new_commentaire_to_expert(dossier, avis, expert)
|
|
|
|
I18n.with_locale(dossier.user_locale) do
|
|
|
|
@dossier = dossier
|
|
|
|
@avis = avis
|
|
|
|
@subject = default_i18n_subject(dossier_id: dossier.id, libelle_demarche: dossier.procedure.libelle)
|
|
|
|
|
|
|
|
mail(to: expert.email, subject: @subject)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-18 07:10:26 +02:00
|
|
|
def self.critical_email?(action_name)
|
|
|
|
false
|
|
|
|
end
|
2017-05-02 15:37:06 +02:00
|
|
|
end
|