dedup 'to' array

Phillip Davis created

Change summary

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

Detailed changes

sgx-bwmsgsv2.rb 🔗

@@ -781,6 +781,10 @@ class WebhookHandler < Goliath::API
 			return [400, {}, "OK"]
 		end
 
+		jparams['to'].reject! { |num|
+			num == users_num || num == others_num
+		}
+
 		return [400, {}, "Missing params\n"] unless users_num && others_num
 		return [400, {}, "Missing params\n"] unless jparams['to'].is_a?(Array)
 
@@ -867,11 +871,6 @@ class WebhookHandler < Goliath::API
 					addrs.add_child(addr1)
 
 					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'