From 4324e44d375bd275132bada0aa0405973584786c Mon Sep 17 00:00:00 2001 From: "Francisco das Chagas S. Jr" <79976550+fchagasjr@users.noreply.github.com> Date: Sat, 30 Dec 2023 23:16:06 -0500 Subject: [PATCH] Email preview uncaught exception (#5459) Add bugsnag_active default value to FundRequestMailer --- app/mailers/fund_request_mailer.rb | 8 +++++--- lib/mailers/previews/fund_request_mailer_preview.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/mailers/fund_request_mailer.rb b/app/mailers/fund_request_mailer.rb index 41d5b9b559..f2cf93e2fc 100644 --- a/app/mailers/fund_request_mailer.rb +++ b/app/mailers/fund_request_mailer.rb @@ -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 @@ -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 diff --git a/lib/mailers/previews/fund_request_mailer_preview.rb b/lib/mailers/previews/fund_request_mailer_preview.rb index 8ace36b744..f19137efd7 100644 --- a/lib/mailers/previews/fund_request_mailer_preview.rb +++ b/lib/mailers/previews/fund_request_mailer_preview.rb @@ -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