fix group picture msg - now from group, not sender

Denver Gingerich created

Prior to this commit, picture messages sent to a group would appear to
come from just the sender, without any mention of the group (i.e. as
if the sender had sent the picture only to the SGX user).  With this
change, picture messages are correctly shown as being from the group,
utilizing the address list creation added in 90331bc.  Note that a
deep clone of the template message is required (via .copy) to ensure
that send_media() doesn't modify the original, which often contains
text that we need to send separately (done later in the code).

Change summary

sgx-bwmsgsv2.rb | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

Detailed changes

sgx-bwmsgsv2.rb 🔗

@@ -104,7 +104,7 @@ module SGXbwmsgsv2
 		client.register_handler_before(type, *guards, &block)
 	end
 
-	def self.send_media(from, to, media_url, desc=nil, subject=nil)
+	def self.send_media(from, to, media_url, desc=nil, subject=nil, m=nil)
 		# we assume media_url is of the form (always the case so far):
 		#  https://messaging.bandwidth.com/api/v2/users/[u]/media/[path]
 
@@ -117,6 +117,10 @@ module SGXbwmsgsv2
 
 		# put URL in the body (so Conversations will still see it)...
 		msg = Blather::Stanza::Message.new(to, proxy_url)
+		if m
+			msg = m
+			msg.body = proxy_url
+		end
 		msg.from = from
 		msg.subject = subject if subject
 
@@ -917,7 +921,8 @@ class WebhookHandler < Goliath::API
 						SGXbwmsgsv2.send_media(
 							others_num + '@' +
 							ARGV[0],
-							bare_jid, media_url
+							bare_jid, media_url,
+							nil, nil, msg.copy
 						)
 					end
 				end unless not jparams['media']