Send notifications using Cheogram whispers

Stephen Paul Weber created

This way they don't need an assigned tel to work.

Change summary

bin/billing_monthly_cronjob          |  9 ++++++---
bin/process_pending_btc_transactions | 11 +++++------
2 files changed, 11 insertions(+), 9 deletions(-)

Detailed changes

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)

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