Class: ErrorReportMailer

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

Instance Method Summary collapse

Instance Method Details

#auth_server_down(at) ⇒ Object



48
49
50
51
52
53
54
# File 'app/mailers/error_report_mailer.rb', line 48

def auth_server_down(at)
  mail(
    from:    '[email protected]',
    subject: 'Authentication server is down!',
    body:    at.strftime("Lost contact on %m/%d/%Y at %I:%M%p. We're running on cache!")
  )
end

#auth_server_up(at) ⇒ Object



56
57
58
59
60
61
62
# File 'app/mailers/error_report_mailer.rb', line 56

def auth_server_up(at)
  mail(
    from:    '[email protected]',
    subject: 'Authentication server back up!',
    body:    at.strftime("Just got a response at %I:%M%p")
  )
end

#send_report(user, params) ⇒ Object



4
5
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/mailers/error_report_mailer.rb', line 4

def send_report(user, params)
  @user  = user || User.find_by(id: params[:user_id])
  if ["Softwear CRM", "Softwear Production"].include?(app_name)
    @order = Order.find_by(id: params[:order_id])

    if @user.nil?
      from_customer = true

      if @order.nil?
        @user = OpenStruct.new(
          email:     '[email protected]',
          full_name: 'Unknown Customer'
        )
      else
        @user = OpenStruct.new(
          email:     @order.email,
          full_name: "(Customer) #{@order.full_name}"
        )
      end
    end
    
  end
  
  if @user.nil?
    @user = OpenStruct.new(
      email:     '[email protected]',
      full_name: 'Unknown Customer'
    )
  end

  @error_class     = params[:error_class]
  @error_message   = params[:error_message]
  @backtrace       = params[:backtrace]
  @user_message    = params[:user_message]
  @additional_info = params[:additional_info]

  mail(
    from:     from_customer ? '[email protected]' : @user.email,
    reply_to: @user.email,
    to:       '[email protected]',
    subject:  "#{app_name} Error Report from #{@user.full_name}"
  )
end