From 6665370def4be4097eda0de37d29c288954936ed Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 17 Nov 2021 16:00:37 -0500 Subject: [PATCH] No low balance if not registered If cancelled or expired or not-yet-registered, don't auto top up or notify about low balance. --- lib/low_balance.rb | 2 ++ sgx_jmp.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/low_balance.rb b/lib/low_balance.rb index d168782..c97341a 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 91a94dc..e08b52c 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)) -- 2.45.2