diff --git a/lib/low_balance.rb b/lib/low_balance.rb index d16878203e1ca85b144820c9a71abc0e31a6fb52..c97341a2fd29d590a3784023410b18bb42534308 100644 --- a/lib/low_balance.rb +++ b/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 diff --git a/sgx_jmp.rb b/sgx_jmp.rb index 91a94dc563bb364eacd513454b166897e73f309f..e08b52c774150d2139561ee092c24b5088353034 100644 --- a/sgx_jmp.rb +++ b/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))