From 8753120aeef14e9adad15f10d8827cb8fcf44260 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Mon, 6 Feb 2017 22:30:06 +0000 Subject: [PATCH] if both users on sgx-catapult deliver msg directly We don't support delivery receipts or picture messaging with this feature yet - those should be straight-forward and are coming soon. --- sgx-catapult.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sgx-catapult.rb b/sgx-catapult.rb index 48fc98f46d52a8d1316b2a25fc5d373d7c06bc33..c5461e799268aa1271968f0a3af04f8e0c3a73b0 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.018\n\n" +puts "Soprani.ca/SMS Gateway for XMPP - Catapult v0.019\n\n" if ARGV.size != 9 then puts "Usage: sgx-catapult.rb " + @@ -118,6 +118,23 @@ module SGXcatapult conn.write ["LRANGE", cred_key, 0, 3] user_id, api_token, api_secret, users_num = conn.read + + # if the destination user is in the system just pass on directly + jid_key = "catapult_jid-" + num_dest + conn.write ["EXISTS", jid_key] + if conn.read > 0 + conn.write ["GET", jid_key] + m.to = conn.read + + m.from = users_num + '@' + ARGV[0] + + puts 'XRESPONSE0: ' + m.inspect + write_to_stream m + + conn.disconnect + next + end + conn.disconnect uri = URI.parse('https://api.catapult.inetwork.com')