Change summary
bin/sim_job | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
Detailed changes
@@ -65,6 +65,7 @@ CONFIG[:creds] = {}
require_relative "../lib/async_braintree"
require_relative "../lib/blather_notify"
require_relative "../lib/customer_repo"
+require_relative "../lib/expiring_lock"
require_relative "../lib/low_balance"
require_relative "../lib/postgres"
require_relative "../lib/sim_repo"
@@ -170,10 +171,12 @@ class SimWarn
include SimAction
def notify
- m = Blather::Stanza::Message.new
- m.body = "Your SIM #{iccid} only has " \
- "#{(@sim.remaining_usage_kb / 1024).to_i} MB left"
- customer.stanza_to(m)
+ ExpiringLog.new("jmp_customer_sim_warn-#{customer.customer_id}") do
+ m = Blather::Stanza::Message.new
+ m.body = "Your SIM #{iccid} only has " \
+ "#{(@sim.remaining_usage_kb / 1024).to_i} MB left"
+ customer.stanza_to(m)
+ end
end
def call
@@ -194,9 +197,11 @@ class SimAnnual
include SimAction
def notify
- m = Blather::Stanza::Message.new
- m.body = "Your SIM #{iccid} only has #{@sim.remaining_days} days left"
- customer.stanza_to(m)
+ ExpiringLog.new("jmp_customer_sim_annual-#{customer.customer_id}") do
+ m = Blather::Stanza::Message.new
+ m.body = "Your SIM #{iccid} only has #{@sim.remaining_days} days left"
+ customer.stanza_to(m)
+ end
end
def annual_price