[Fix #198] Add a Commentaire when we send a Notification email to a user

This commit is contained in:
gregoirenovel 2017-05-11 18:07:37 +02:00
parent 49d1a1c0b8
commit 70f637f088
2 changed files with 26 additions and 3 deletions

View file

@ -1,13 +1,15 @@
class NotificationMailer < ApplicationMailer
default to: Proc.new { @user.email }
after_action :create_commentaire_for_notification, only: :send_notification
def send_notification dossier, mail_template
vars_mailer(dossier)
obj = mail_template.object_for_dossier dossier
body = mail_template.body_for_dossier dossier
@obj = mail_template.object_for_dossier dossier
@body = mail_template.body_for_dossier dossier
mail(subject: obj) { |format| format.html { body } }
mail(subject: @obj) { |format| format.html { @body } }
end
def new_answer dossier
@ -16,6 +18,14 @@ class NotificationMailer < ApplicationMailer
private
def create_commentaire_for_notification
Commentaire.create(
dossier: @dossier,
email: "contact@tps.apientreprise.fr",
body: ["[#{@obj}]", @body].join("<br><br>")
)
end
def vars_mailer dossier
@dossier = dossier
@user = dossier.user