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/invite_mailer
|
2016-02-08 18:16:18 +01:00
|
|
|
|
class InviteMailer < ApplicationMailer
|
2018-12-20 09:49:41 +01:00
|
|
|
|
layout 'mailers/layout'
|
|
|
|
|
|
2018-03-20 17:47:37 +01:00
|
|
|
|
def invite_user(invite)
|
2024-06-24 10:54:55 +02:00
|
|
|
|
bypass_unverified_mail_protection!
|
|
|
|
|
|
2021-05-26 15:16:30 +02:00
|
|
|
|
subject = "Participez à l'élaboration d’un dossier"
|
2022-06-13 16:00:41 +02:00
|
|
|
|
targeted_user_link = invite.targeted_user_link || invite.create_targeted_user_link(target_context: 'invite',
|
|
|
|
|
target_model: invite,
|
|
|
|
|
user: invite.user)
|
|
|
|
|
@url = targeted_user_link_url(targeted_user_link)
|
2018-05-31 15:53:04 +02:00
|
|
|
|
if invite.user.present?
|
|
|
|
|
send_mail(invite, subject, invite.email_sender)
|
|
|
|
|
end
|
2016-02-08 18:16:18 +01:00
|
|
|
|
end
|
|
|
|
|
|
2018-03-20 17:47:37 +01:00
|
|
|
|
def invite_guest(invite)
|
2024-06-24 10:54:55 +02:00
|
|
|
|
bypass_unverified_mail_protection!
|
|
|
|
|
|
2018-05-31 15:50:13 +02:00
|
|
|
|
subject = "#{invite.email_sender} vous invite à consulter un dossier"
|
2022-06-13 16:00:41 +02:00
|
|
|
|
targeted_user_link = invite.targeted_user_link || invite.create_targeted_user_link(target_context: 'invite',
|
|
|
|
|
target_model: invite)
|
|
|
|
|
@url = targeted_user_link_url(targeted_user_link)
|
2016-02-08 18:16:18 +01:00
|
|
|
|
|
2018-05-31 15:52:50 +02:00
|
|
|
|
send_mail(invite, subject, invite.email_sender)
|
2016-02-08 18:16:18 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
2018-05-31 15:52:50 +02:00
|
|
|
|
def send_mail(invite, subject, reply_to)
|
2016-02-08 18:16:18 +01:00
|
|
|
|
@invite = invite
|
2018-05-31 15:52:50 +02:00
|
|
|
|
email = invite.email
|
2016-02-08 18:16:18 +01:00
|
|
|
|
|
2024-03-26 18:58:13 +01:00
|
|
|
|
configure_defaults_for_email(email)
|
|
|
|
|
|
2017-05-11 18:24:43 +02:00
|
|
|
|
mail(to: email,
|
2018-09-20 14:34:49 +02:00
|
|
|
|
subject: subject,
|
|
|
|
|
reply_to: reply_to)
|
2016-02-08 18:16:18 +01:00
|
|
|
|
end
|
2023-01-23 14:56:05 +01:00
|
|
|
|
|
2023-10-18 07:10:26 +02:00
|
|
|
|
def self.critical_email?(action_name)
|
2023-01-23 14:56:05 +01:00
|
|
|
|
true
|
|
|
|
|
end
|
2016-02-08 18:16:18 +01:00
|
|
|
|
end
|