From a91a5759c55560943b2e0322081821db65d87711 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Sat, 18 Apr 2020 21:39:09 +0000 Subject: [PATCH] XEP-0033 now actually supported, offers group text Now the XEP-0033 support indicated in 8e8fa1b is actually present, and allows the SGX to receive group texts in this manner per the details in https://wiki.soprani.ca/SGX/GroupMMS - the other method added in 96856c7 remains as of this commit, but will be removed shortly. Note that the method parameter for validate_num had to change slightly here, but the single-number validation code needed no changes at all. --- sgx-bwmsgsv2.rb | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index c7a9f92f565e622bda66a2365bde698222953f11..0109577e3b013b6bf330fa9299c8f35cef958b39 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -331,8 +331,47 @@ module SGXbwmsgsv2 } end - def self.validate_num(num) - EMPromise.resolve(num.to_s).then { |num_dest| + def self.validate_num(m) + # if sent to SGX domain use https://wiki.soprani.ca/SGX/GroupMMS + if m.to == ARGV[0] + an = m.children.find { |v| v.element_name == "addresses" + } + if not an + return EMPromise.reject([:cancel, + 'item-not-found']) + end + puts "ADRXEP: found an addresses node - iterate addrs.." + + nums = [] + an.children.each do |e| + num = '' + type = '' + e.attributes.each do |c| + if c[0] == 'type' + if c[1] != 'to' + # TODO: error + end + type = c[1].to_s + elsif c[0] == 'uri' + if !c[1].to_s.start_with? 'sms:' + # TODO: error + end + num = c[1].to_s[4..-1] + # TODO: confirm num validates + else + # TODO: error - unexpected name + end + end + if num.empty? or type.empty? + # TODO: error + end + nums << num + end + return nums + end + + # if not sent to SGX domain, then assume destination is in 'to' + EMPromise.resolve(m.to.node.to_s).then { |num_dest| if num_dest =~ /\A\+?[0-9]+(?:;.*)?\Z/ next num_dest if num_dest[0] == '+' shortcode = extract_shortcode(num_dest) @@ -384,7 +423,7 @@ module SGXbwmsgsv2 message :body do |m| EMPromise.all([ - validate_num(m.to.node), + validate_num(m), fetch_catapult_cred_for(m.from) ]).then { |(num_dest, creds)| jid_key = "catapult_jid-#{num_dest}"