From 91ff28946fbe18d4da3d352fc4e422e0b1e99468 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Thu, 30 Apr 2020 02:48:49 +0000 Subject: [PATCH] update send_media() for V2, including field offset Since the media is stored at a completely different place with the V2 API, we need to update the send_media() method accordingly, so that media (such as picture messages) is passed on correctly. While this still technically requires an update to mpx-catapult, that is beyond the scope of this project for now, particularly because it is a very minor change there (it will remain in sgx-catapult for now). So with this fix the URLs will be correct, assuming that the mpx-catapult serving up this instance's URLs has been patched accordingly. --- sgx-bwmsgsv2.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 89668564b6c8cb39ff1d2d98da1b6acf0f02f167..87eecc9818b2eb2b2cc97a258f3d1b5e99e182ff 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -106,11 +106,11 @@ module SGXbwmsgsv2 def self.send_media(from, to, media_url, desc=nil, subject=nil) # we assume media_url is of the form (always the case so far): - # https://api.catapult.inetwork.com/v1/users/[uid]/media/[file] + # https://messaging.bandwidth.com/api/v2/users/[u]/media/[path] # the caller must guarantee that 'to' is a bare JID proxy_url = ARGV[6] + WEBrick::HTTPUtils.escape(to) + '/' + - media_url.split('/', 8)[7] + media_url.split('/', 9)[8] puts 'ORIG_URL: ' + media_url puts 'PROX_URL: ' + proxy_url