emails: use the notification template for more messages

This allow to display the procedure logo and contact footer
at the bottom of these emails.
This commit is contained in:
Pierre de La Morinerie 2019-07-17 12:41:37 +00:00
parent b157d860d2
commit 8b80c48679
3 changed files with 28 additions and 13 deletions

View file

@ -2,4 +2,22 @@ class ApplicationMailer < ActionMailer::Base
helper :application # gives access to all helpers defined within `application_helper`.
default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>"
layout 'mailer'
# Attach the procedure logo to the email (if any).
# Returns the attachment url.
def attach_logo(procedure)
return nil if !procedure.logo?
begin
logo_filename = procedure.logo.filename
attachments.inline[logo_filename] = procedure.logo.read
attachments[logo_filename].url
rescue StandardError => e
# A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ?
Raven.extra_context(procedure_id: procedure.id)
Raven.capture_exception(e)
nil
end
end
end