From dc203f3b1b7400d01b692243bb2ba17dd8749a36 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Fri, 13 Jan 2017 14:34:03 +0000 Subject: [PATCH] deliver msg text; working full message round-trip --- sgx-catapult.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/sgx-catapult.rb b/sgx-catapult.rb index 9e43a2b4ed5d6cae5fa103fcd233fd529c1bcfce..eb4d7a638a26a595271b1e641b669b21a94af132 100755 --- a/sgx-catapult.rb +++ b/sgx-catapult.rb @@ -421,8 +421,30 @@ class WebhookHandler < Goliath::API bare_jid = conn.read[0] conn.disconnect - # TODO: actually send the message and/or deliver receipt ok/fail - msg = Blather::Stanza::Message.new(bare_jid, 'hi') + msg = '' + case params['direction'] + when 'in' + text = '' + case params['eventType'] + when 'sms' + text = params['text'] + when 'mms' + text = "MMS (pic not implemented) with text: " + + params['text'] + else + text = "unknown type (#{params['eventType']})" + + " with text: " + params['text'] + + # TODO log/notify of this properly + puts text + end + + msg = Blather::Stanza::Message.new(bare_jid, text) + else # per prior switch, this is: params['direction'] == 'out' + # TODO: actually send delivery receipt + msg = Blather::Stanza::Message.new(bare_jid, '') + end + msg.from = others_num + '@' + ARGV[0] SGXcatapult.write(msg)