Method: Notifier#message_notification

Defined in:
app/mailers/notifier.rb

#message_notification(message_id) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/mailers/notifier.rb', line 2

def message_notification(message_id)
  message = Message.find(message_id)
  I18n.locale = message.receiver.profile.locale.try(:to_sym) || I18n.default_locale
  from = "#{LibraryGroup.system_name(message.receiver.profile.locale)} <#{LibraryGroup.site_config.user.email}>"
  if message.subject
    subject = message.subject
  else
    subject = I18n.t('message.new_message_from_library', library: LibraryGroup.system_name(message.receiver.user.profile.locale))
  end
  if message.sender
    @sender_name = message.sender.username
  else
    @sender_name = LibraryGroup.system_name(message.receiver.profile.locale)
  end
  @message = message
  @locale = message.receiver.profile.locale
  mail(from: from, to: message.receiver.email, subject: subject)
end