No low balance if not registered

Stephen Paul Weber created

If cancelled or expired or not-yet-registered, don't auto top up or notify about
low balance.

Change summary

lib/low_balance.rb | 2 ++
sgx_jmp.rb         | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)

Detailed changes

lib/low_balance.rb 🔗

@@ -5,6 +5,8 @@ require_relative "transaction"
 
 class LowBalance
 	def self.for(customer)
+		return Locked.new unless customer.registered?
+
 		ExpiringLock.new(
 			"jmp_customer_low_balance-#{customer.customer_id}",
 			expiry: 60 * 60 * 24 * 7

sgx_jmp.rb 🔗

@@ -178,7 +178,7 @@ EM.error_handler(&method(:panic))
 
 def poll_for_notify(db)
 	db.wait_for_notify_defer.then { |notify|
-		CustomerRepo.new.find(notify[:extra])
+		CustomerRepo.new(sgx_repo: Bwmsgsv2Repo.new).find(notify[:extra])
 	}.then(&LowBalance.method(:for)).then(&:notify!).then {
 		poll_for_notify(db)
 	}.catch(&method(:panic))