~singpolyma/jmp-pay

e0ba65ce4f92b8f692969d8fe9c68ea49a024d50 — Stephen Paul Weber 1 year, 5 months ago 77715a3
Send notifications using Cheogram whispers

This way they don't need an assigned tel to work.
2 files changed, 11 insertions(+), 9 deletions(-)

M bin/billing_monthly_cronjob
M bin/process_pending_btc_transactions
M bin/billing_monthly_cronjob => bin/billing_monthly_cronjob +6 -3
@@ 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)

M bin/process_pending_btc_transactions => bin/process_pending_btc_transactions +5 -6
@@ 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