update send_media() for V2, including field offset
Denver Gingerich
created
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.
@@ -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