Sha256: 61229dfa93287aaa665ad1edc3c905af1e145eb0d9369abc85477fc24aa4b4c4

Contents?: true

Size: 968 Bytes

Versions: 52

Compression:

Stored size: 968 Bytes

Contents

class DiscoveredMailer < ::ApplicationMailer
  helper :discovered_hosts
  def discovered_summary(options = {})
    user = if options[:user].kind_of? User
             options[:user]
           elsif options[:user].kind_of? Integer
             User.find(options[:user])
           else
             raise ::Foreman::Exception.new(N_('Invalid user type of %s was provided'), options[:user].class.to_s)
           end

    unless user.mail_enabled?
      Rails.logger.debug("The user #{user.id} does not email enabled")
      return
    end
    begin
      Time.zone = user.timezone
    rescue ArgumentError
      Time.zone = 'UTC'
    end

    set_url
    @time = options[:time] || 1.day.ago
    @discovered_hosts = Host::Discovered.authorized_as(user, :view_discovered_hosts, Host::Discovered).where("created_at >= ?", @time)
    set_locale_for(user) do
      subject = _("Discovered hosts summary")
      mail(:to => user.mail, :subject => subject)
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
foreman_discovery-25.0.0 app/mailers/discovered_mailer.rb
foreman_discovery-24.0.2 app/mailers/discovered_mailer.rb
foreman_discovery-23.0.2 app/mailers/discovered_mailer.rb
foreman_discovery-24.0.1 app/mailers/discovered_mailer.rb
foreman_discovery-24.0.0 app/mailers/discovered_mailer.rb
foreman_discovery-23.0.1 app/mailers/discovered_mailer.rb
foreman_discovery-23.0.0 app/mailers/discovered_mailer.rb
foreman_discovery-22.0.4 app/mailers/discovered_mailer.rb
foreman_discovery-21.0.5 app/mailers/discovered_mailer.rb
foreman_discovery-22.0.2 app/mailers/discovered_mailer.rb
foreman_discovery-21.0.4 app/mailers/discovered_mailer.rb
foreman_discovery-21.0.3 app/mailers/discovered_mailer.rb
foreman_discovery-21.0.2 app/mailers/discovered_mailer.rb
foreman_discovery-19.0.5 app/mailers/discovered_mailer.rb
foreman_discovery-19.0.4 app/mailers/discovered_mailer.rb
foreman_discovery-21.0.1 app/mailers/discovered_mailer.rb
foreman_discovery-19.0.3 app/mailers/discovered_mailer.rb
foreman_discovery-21.0.0 app/mailers/discovered_mailer.rb
foreman_discovery-19.0.2 app/mailers/discovered_mailer.rb
foreman_discovery-20.0.1 app/mailers/discovered_mailer.rb