From e0ba65ce4f92b8f692969d8fe9c68ea49a024d50 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 8 Mar 2021 10:06:30 -0500 Subject: [PATCH] Send notifications using Cheogram whispers This way they don't need an assigned tel to work. --- bin/billing_monthly_cronjob | 9 ++++++--- bin/process_pending_btc_transactions | 11 +++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/billing_monthly_cronjob b/bin/billing_monthly_cronjob index 129644b..09a4fc2 100755 --- a/bin/billing_monthly_cronjob +++ b/bin/billing_monthly_cronjob @@ -6,7 +6,8 @@ # notify_using = { # jid = "", # password = "", -# target = \(tel: Text) -> "${tel}@cheogram.com" +# target = \(jid: Text) -> "+12266669977@cheogram.com", +# body = \(jid: Text) -> \(body: Text) -> "/msg ${jid} ${body}", # }, # plans = ./plans.dhall # }' @@ -137,8 +138,10 @@ class ExpiredCustomer jid = REDIS.get("jmp_customer_jid-#{@row['customer_id']}") tel = REDIS.lindex("catapult_cred-#{jid}", 3) BlatherNotify.say( - CONFIG[:notify_using][:target].call(tel.to_s), - format_renewal_notification(tel) + CONFIG[:notify_using][:target].call(jid), + CONFIG[:notify_using][:body].call( + jid, format_renewal_notification(tel) + ) ) stats.add(:not_renewed, 1) diff --git a/bin/process_pending_btc_transactions b/bin/process_pending_btc_transactions index d82927c..0c39f44 100755 --- a/bin/process_pending_btc_transactions +++ b/bin/process_pending_btc_transactions @@ -8,7 +8,8 @@ # notify_using = { # jid = "", # password = "", -# target = \(tel: Text) -> "${tel}@cheogram.com" +# target = \(jid: Text) -> "+12266669977@cheogram.com", +# body = \(jid: Text) -> \(body: Text) -> "/msg ${jid} ${body}", # }, # electrum = env:ELECTRUM_CONFIG, # plans = ./plans.dhall, @@ -156,7 +157,7 @@ class Plan ) insert(start: Date.today, expire: @go_until) REDIS.del("pending_plan_for-#{@customer.id}") - # TODO: @customer.notify("Your account has been activated") + @customer.notify("Your account has been activated") end end end @@ -173,11 +174,9 @@ class Customer def notify(body) jid = REDIS.get("jmp_customer_jid-#{@customer_id}") raise "No JID for #{customer_id}" unless jid - tel = REDIS.lindex("catapult_cred-#{jid}", 3) - return unless tel BlatherNotify.say( - CONFIG[:notify_using][:target].call(tel.to_s), - body + CONFIG[:notify_using][:target].call(jid), + CONFIG[:notify_using][:body].call(jid, body) ) end -- 2.38.5