~singpolyma/sgx-jmp

6665370def4be4097eda0de37d29c288954936ed — Stephen Paul Weber 2 months ago 028e7a1
No low balance if not registered

If cancelled or expired or not-yet-registered, don't auto top up or notify about
low balance.
2 files changed, 3 insertions(+), 1 deletions(-)

M lib/low_balance.rb
M sgx_jmp.rb
M lib/low_balance.rb => lib/low_balance.rb +2 -0
@@ 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

M sgx_jmp.rb => sgx_jmp.rb +1 -1
@@ 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))