move media handler into active block - no work yet

Denver Gingerich created

Move the media handler code from the now-inactive 'mms' block (since
V2 messages don't have that type) into the new 'message-received'
block.  While this does cause the user to receive the media message,
there are still at least two problems:

1. This commit breaks non-MMS messages (since 'media' is undefined).

2. Media messages are not delivered with the correct URL (needs mpx?).

Anyway, we know about these, but wanted to keep this commit short and
sweet so that changes to the actual media handler are separate from
the commit that merely moves the code from one place to another
without changes to the media handler code itself.

Change summary

sgx-bwmsgsv2.rb | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)

Detailed changes

sgx-bwmsgsv2.rb 🔗

@@ -847,19 +847,6 @@ class WebhookHandler < Goliath::API
 				text = jparams['text']
 			when 'mms'
 				has_media = false
-				jparams['media'].each do |media_url|
-					if not media_url.end_with?(
-						'.smil', '.txt', '.xml'
-					)
-
-						has_media = true
-						SGXbwmsgsv2.send_media(
-							others_num + '@' +
-							ARGV[0],
-							bare_jid, media_url
-						)
-					end
-				end
 
 				if jparams['text'].empty?
 					if not has_media
@@ -920,6 +907,20 @@ class WebhookHandler < Goliath::API
 					# TODO: delete
 					puts "RESPONSE9: #{msg.inspect}"
 				end
+
+				jparams['media'].each do |media_url|
+					if not media_url.end_with?(
+						'.smil', '.txt', '.xml'
+					)
+
+						has_media = true
+						SGXbwmsgsv2.send_media(
+							others_num + '@' +
+							ARGV[0],
+							bare_jid, media_url
+						)
+					end
+				end
 			else
 				text = "unknown type (#{type})"\
 					" with text: " + jparams['text']