houdiniproject/houdini

`NonprofitMailer.refund` incorrectly tries to send even if nothing in `to:`

wwahammy opened this issue · 2 comments

It's possible for the nonprofit to have no users set to receive notifications of payments, i.e. the call on line 23

@emails = QueryUsers.nonprofit_user_emails(@nonprofit.id, 'notify_payments')
mail(to: @emails, subject: "A new refund has been made for $#{Format::Currency.cents_to_dollars(@refund.amount)}")
returns an empty array. That makes the call to mail on line 24 error out (at least if you're using AWS SES) as it's incorrect to send an email with nothing in the "to:" header.

The fix would be to add a guard on line 24 against @emails being an empty array.

Me (@victordscabral), @kayrocesar and @joaobisi will work on it.

Link to the PR: #1460