From 73f30ab203bf36b2f68ab944d4ebbf2cb210bed3 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Fri, 3 Feb 2017 13:29:52 +0000 Subject: [PATCH] fix schema: catapult_num now _jid to reflect usage The "catapult_num-N" keys have always stored the JID associated with N so it makes more sense to call this "catapult_jid-N" - this is really a "JID key", not a "number key" (hence the accompanying variable name change). Furthermore, we will be adding another number-indexed table to the schema soon ("catapult_fwd-N"), which will eventually be used for forwarding calls, but is initially mostly a placeholder in the DB, used only for sending verification codes via phone from jmp-register. It makes much less sense to have "catapult_num-N" in this situation. --- sgx-catapult.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sgx-catapult.rb b/sgx-catapult.rb index 7176c6e518575662792205200d68fb243820c4e6..0233d4d4a1adce1e2154010bac90a53e7212cea8 100755 --- a/sgx-catapult.rb +++ b/sgx-catapult.rb @@ -30,7 +30,7 @@ require 'goliath/api' require 'goliath/server' require 'log4r' -puts "Soprani.ca/SMS Gateway for XMPP - Catapult v0.016" +puts "Soprani.ca/SMS Gateway for XMPP - Catapult v0.017" if ARGV.size != 9 then puts "Usage: sgx-catapult.rb " + @@ -524,7 +524,7 @@ module SGXcatapult if response.code == '200' params = JSON.parse response.body if params['numberState'] == 'enabled' - num_key = "catapult_num-" + phone_num + jid_key = "catapult_jid-" + phone_num bare_jid = i.from.to_s.split('/', 2)[0] cred_key = "catapult_cred-" + bare_jid @@ -534,7 +534,7 @@ module SGXcatapult conn.connect(ARGV[4], ARGV[5].to_i) # TODO: use SETNX instead - conn.write ["EXISTS", num_key] + conn.write ["EXISTS", jid_key] if conn.read == 1 conn.disconnect @@ -556,7 +556,7 @@ module SGXcatapult next end - conn.write ["SET", num_key, bare_jid] + conn.write ["SET", jid_key, bare_jid] if conn.read != 1 conn.disconnect @@ -739,7 +739,7 @@ class WebhookHandler < Goliath::API return [200, {}, "OK"] end - num_key = "catapult_num-" + users_num + jid_key = "catapult_jid-" + users_num if others_num[0] != '+' # TODO: check that others_num actually a shortcode first @@ -750,11 +750,11 @@ class WebhookHandler < Goliath::API conn = Hiredis::Connection.new conn.connect(ARGV[4], ARGV[5].to_i) - conn.write ["EXISTS", num_key] + conn.write ["EXISTS", jid_key] if conn.read == 0 conn.disconnect - puts "num_key (#{num_key}) DNE; Catapult misconfigured?" + puts "jid_key (#{jid_key}) DNE; Catapult misconfigured?" # TODO: likely not appropriate; give error to Catapult? # TODO: add text re credentials not being registered @@ -763,7 +763,7 @@ class WebhookHandler < Goliath::API return [200, {}, "OK"] end - conn.write ["GET", num_key] + conn.write ["GET", jid_key] bare_jid = conn.read conn.disconnect