Skip to content

Commit

Permalink
Email preview uncaught exception (#5459)
Browse files Browse the repository at this point in the history
Add bugsnag_active default value to FundRequestMailer
  • Loading branch information
fchagasjr authored Dec 31, 2023
1 parent d2161d9 commit 4324e44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/mailers/fund_request_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class FundRequestMailer < ApplicationMailer
layout "fund_layout"

def send_request(_user, fund_request)
def send_request(_user, fund_request, bugsnag_active = true)
to_recipient_email = ENV["FUND_REQUEST_RECIPIENT_EMAIL"]

submitter_email = fund_request.submitter_email
Bugsnag.notify("No user for FUND_REQUEST_RECIPIENT_EMAIL for fund request from: #{submitter_email}") unless to_recipient_email
if bugsnag_active && !to_recipient_email
Bugsnag.notify("No user for FUND_REQUEST_RECIPIENT_EMAIL for fund request from: #{submitter_email}")
end
@inputs = fund_request.as_json
submitter_name = fund_request.submitter_email&.split("@")&.first
begin
Expand All @@ -16,7 +18,7 @@ def send_request(_user, fund_request)
).write_to_file.read
attachments.inline["fund-request-#{Date.today}-#{submitter_name}.pdf"] = pdf_attachment
rescue => e
Bugsnag.notify(e)
Bugsnag.notify(e) if bugsnag_active
end
mail(layout: nil, to: [to_recipient_email, submitter_email], subject: "Fund request from #{submitter_email}")
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mailers/previews/fund_request_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ def send_request
extra_information: "Sample Extra Information"
)

FundRequestMailer.send_request(nil, fund_request)
FundRequestMailer.send_request(nil, fund_request, false)
end
end

0 comments on commit 4324e44

Please # to comment.