@@ -24,7 +24,7 @@ def low_threshold_reached(account)
2424 System ::EventSubscription ::CONST ::EVENT_ACCOUNT_LOW_THRESHOLD_REACHED ,
2525 subject : "Account with id #{ account . id } low balance" ,
2626 message : account_threshold_message ( account ) ,
27- additional_contacts : account_contacts ( account ) ,
27+ additional_contacts : account_email_recipients ( account ) ,
2828 event_data : account_threshold_data ( account )
2929 )
3030 end
@@ -34,7 +34,7 @@ def high_threshold_reached(account)
3434 System ::EventSubscription ::CONST ::EVENT_ACCOUNT_HIGH_THRESHOLD_REACHED ,
3535 subject : "Account with id #{ account . id } high balance" ,
3636 message : account_threshold_message ( account ) ,
37- additional_contacts : account_contacts ( account ) ,
37+ additional_contacts : account_email_recipients ( account ) ,
3838 event_data : account_threshold_data ( account )
3939 )
4040 end
@@ -44,7 +44,7 @@ def low_threshold_cleared(account)
4444 System ::EventSubscription ::CONST ::EVENT_ACCOUNT_LOW_THRESHOLD_CLEARED ,
4545 subject : "Account with id #{ account . id } low balance cleared" ,
4646 message : account_threshold_message ( account ) ,
47- additional_contacts : account_contacts ( account ) ,
47+ additional_contacts : account_email_recipients ( account ) ,
4848 event_data : account_threshold_data ( account )
4949 )
5050 end
@@ -54,7 +54,7 @@ def high_threshold_cleared(account)
5454 System ::EventSubscription ::CONST ::EVENT_ACCOUNT_HIGH_THRESHOLD_CLEARED ,
5555 subject : "Account with id #{ account . id } high balance cleared" ,
5656 message : account_threshold_message ( account ) ,
57- additional_contacts : account_contacts ( account ) ,
57+ additional_contacts : account_email_recipients ( account ) ,
5858 event_data : account_threshold_data ( account )
5959 )
6060 end
@@ -153,6 +153,12 @@ def account_contacts(account)
153153 account . balance_notification_setting . contacts . preload ( contractor : :smtp_connection ) . to_a
154154 end
155155
156+ def account_email_recipients ( account )
157+ return [ ] if YetiConfig . disable_balance_notification_emails
158+
159+ account_contacts ( account )
160+ end
161+
156162 def destination_contacts ( destination )
157163 contact_ids = destination . rateplans . pluck ( :send_quality_alarms_to ) . flatten . compact . uniq
158164 Billing ::Contact . where ( id : contact_ids ) . preload ( contractor : :smtp_connection ) . to_a
0 commit comments