Class: Locomotive::Notifications

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
app/mailers/locomotive/notifications.rb

Instance Method Summary collapse

Instance Method Details

#new_content_entry(account, entry) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/mailers/locomotive/notifications.rb', line 6

def new_content_entry(, entry)
  @site, @account = entry.site, 
  @entry, @type   = entry, entry.content_type

  @domain = entry.site.domains.first ||
    ActionMailer::Base.default_url_options[:host] ||
    'localhost'

  subject = new_content_entry_subject(entry, domain: @domain, type: @type.name, locale: .locale)
  from    = (if top_level_domain = Adomain.domain(@domain)
     "noreply@#{top_level_domain}"
  else
    Locomotive.config.mailer_sender
  end)

  # attach uploaded files
  if @type.public_submission_email_attachments
    entry.file_custom_fields.each do |name|
      next if (file = entry.send(name)&.file).nil?
      attachments[file.filename] = file.read
    end
  end

  mail subject: subject, from: from, to: .email, reply_to: from
end