diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 966318a6963f04ad8504e125ea11d14fe532f326..62c7820e593a2e08afd2500a32b4d2fd6d009e6b 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -270,53 +270,29 @@ module SGXbwmsgsv2 def self.to_catapult_possible_oob(s, num_dest, user_id, token, secret, usern) - xn = s.children.find { |v| v.element_name == "x" } - if not xn - to_catapult(s, nil, num_dest, user_id, token, secret, - usern) - return - end - puts "MMSOOB: found an x node - checking for url node..." - - # TODO: also check for xmlns='jabber:x:oob' in - the below - # is probably fine, though, as non-OOB unlikely - - un = xn.children.find { |v| v.element_name == "url" } - if not un - puts "MMSOOB: no url node found so process as normal" - to_catapult(s, nil, num_dest, user_id, token, secret, - usern) - return - end - puts "MMSOOB: found a url node - checking if to make MMS..." - - REDIS.getbit("catapult_setting_flags-#{s.from.stripped}", - CatapultSettingFlagBits::MMS_ON_OOB_URL).then { |oob_on| - - puts "MMSOOB: found MMS_ON_OOB_URL value is '#{oob_on}'" - if 0 == oob_on - puts "MMSOOB: MMS_ON_OOB_URL off so no MMS send" - to_catapult(s, nil, num_dest, user_id, token, - secret, usern) - next + # TODO: fix indentation + + un = s.at("oob|x > oob|url", oob: "jabber:x:oob") + if not un + puts "MMSOOB: no url node found so process as normal" + to_catapult(s, nil, num_dest, user_id, token, secret, + usern) + return end + puts "MMSOOB: found a url node - checking if to make MMS..." # TODO: check size of file at un.text and shrink if need body = s.respond_to?(:body) ? s.body : '' + # some clients send URI in both body & so delete + s.body = body.sub(/\s*#{Regexp::escape(un.text)}\s*$/, '') + puts "MMSOOB: url text is '#{un.text}'" puts "MMSOOB: the body is '#{body.to_s.strip}'" - # some clients send URI in both body & so delete - if un.text == body.to_s.strip - puts "MMSOOB: url matches body so deleting body" - s.body = '' - end - puts "MMSOOB: sending MMS since found OOB & user asked" to_catapult(s, un.text, num_dest, user_id, token, secret, usern) - } end def self.to_catapult(s, murl, num_dest, user_id, token, secret, usern)