mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-12 23:09:03 +01:00
9c55b9d61f
- when enabled: the user was still logged-in in the backend (F5 and he was logged in the frontend) - when disabled: the user was not logged in the frontend and received a message to confirm his/her email
56 lines
1.9 KiB
Ruby
56 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# Handle most of the emails sent by the platform. Triggered by notifications
|
|
class NotificationsMailer < NotifyWith::NotificationsMailer
|
|
default from: ->(*) { Setting.get('email_from') }
|
|
layout 'notifications_mailer'
|
|
|
|
helper :application
|
|
|
|
def send_mail_by(notification)
|
|
@notification = notification
|
|
@recipient = notification.receiver
|
|
@attached_object = notification.attached_object
|
|
|
|
unless respond_to?(notification.notification_type)
|
|
class_eval %{
|
|
def #{notification.notification_type}
|
|
mail to: @recipient.email,
|
|
subject: t('notifications_mailer.#{notification.notification_type}.subject'),
|
|
template_name: '#{notification.notification_type}',
|
|
content_type: 'text/html'
|
|
end
|
|
}, __FILE__, __LINE__ - 7
|
|
end
|
|
|
|
send(notification.notification_type)
|
|
rescue StandardError => e
|
|
STDERR.puts "[NotificationsMailer] notification cannot be sent: #{e}"
|
|
end
|
|
|
|
def helpers
|
|
ActionController::Base.helpers
|
|
end
|
|
|
|
def notify_user_when_invoice_ready
|
|
attachments[@attached_object.filename] = File.read(@attached_object.file)
|
|
mail(to: @recipient.email,
|
|
subject: t('notifications_mailer.notify_member_invoice_ready.subject'),
|
|
template_name: 'notify_member_invoice_ready')
|
|
end
|
|
|
|
def notify_user_when_avoir_ready
|
|
attachments[@attached_object.filename] = File.read(@attached_object.file)
|
|
mail(to: @recipient.email,
|
|
subject: t('notifications_mailer.notify_member_avoir_ready.subject'),
|
|
template_name: 'notify_member_avoir_ready')
|
|
end
|
|
|
|
def notify_user_when_payment_schedule_ready
|
|
attachments[@attached_object.filename] = File.read(@attached_object.file)
|
|
mail(to: @recipient.email,
|
|
subject: t('notifications_mailer.notify_member_payment_schedule_ready.subject'),
|
|
template_name: 'notify_member_payment_schedule_ready')
|
|
end
|
|
end
|