From d89a1b78d9e2a67c06bb5c2d255d8c4cf0eca52b Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Fri, 1 May 2020 00:21:26 +0000 Subject: [PATCH] fix group picture msg - now from group, not sender 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). --- sgx-bwmsgsv2.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 87eecc9818b2eb2b2cc97a258f3d1b5e99e182ff..0525dd565a712ab869f7bbe6e4d3aaaf3a4a1af8 100755 --- a/sgx-bwmsgsv2.rb +++ b/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']