From b1466a9259680e6ba06a31af5d7b5754bb861712 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Sat, 2 May 2020 20:45:54 +0000 Subject: [PATCH] add incoming group text support for >2 recipients When we first added proper incoming group text support (in 90331bc), we only supported 2 recipients. We also assumed the first recipient was the user, and then just truncated the rest of the recipient list to be just one additional number, as a way of getting it implemented quickly. Now we've added a bit more thought, and a loop to go through all the recipient numbers to add them to the address list we pass on to the user. We also needed to be careful to filter out our own number from the recipient list, as that is already added in the addr1 section above. --- sgx-bwmsgsv2.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 0525dd565a712ab869f7bbe6e4d3aaaf3a4a1af8..bfee7176214aba2b04236129e4a88394525055b1 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -898,13 +898,19 @@ class WebhookHandler < Goliath::API addr1['jid'] = bare_jid addrs.add_child(addr1) - # TODO: actually do N, instead of just 1 - addrn = Nokogiri::XML::Node.new( - 'address', msg.document) - addrn['type'] = 'to' - addrn['uri'] = "sms:#{jparams['to'][1]}" - addrn['delivered'] = 'true' - addrs.add_child(addrn) + jparams['to'].each do |receiver| + if receiver == users_num + # already there in addr1 + next + end + + addrn = Nokogiri::XML::Node.new( + 'address', msg.document) + addrn['type'] = 'to' + addrn['uri'] = "sms:#{receiver}" + addrn['delivered'] = 'true' + addrs.add_child(addrn) + end msg.add_child(addrs)