From f7cb85385984c76d188ef705db6799b34710aff9 Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Wed, 29 Apr 2020 18:12:16 +0000 Subject: [PATCH] delivery receipts: remove some duplicate hack code We added some hacks to not send delivery receipts for group texts (as they were not working correctly with Cheogram in our initial tests), but we did not properly combine them when the second was added, in part to keep the diff looking pretty. So we'll do this now, noting that the first hack was added in d49bf12 and then a copy of it was added in a106c87. Now they are combined. This almost has no functional changes, except that if we were to receive a message with an unknown type for a group text, the corresponding message would no longer be printed due to this warning and early exit occurring first. --- sgx-bwmsgsv2.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index dfd06ec5bf93df22df8ab8b87439cb7a7ff76495..89668564b6c8cb39ff1d2d98da1b6acf0f02f167 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -938,6 +938,12 @@ class WebhookHandler < Goliath::API id = WEBrick::HTTPUtils.unescape(tag_parts[0]) resourcepart = WEBrick::HTTPUtils.unescape(tag_parts[1]) + # TODO: remove this hack + if jparams['to'].length > 1 + puts "WARN! group no rcpt: #{users_num}" + return [200, {}, "OK"] + end + case type when 'message-failed' # create a bare message like the one user sent @@ -946,12 +952,6 @@ class WebhookHandler < Goliath::API msg.from = bare_jid + '/' + resourcepart msg['id'] = id - # TODO: remove this hack - if jparams['to'].length > 1 - puts "WARN! group no rcpt: #{users_num}" - return [200, {}, "OK"] - end - # TODO: add 'errorCode' and/or 'description' val # create an error reply to the bare message msg = Blather::StanzaError.new( @@ -963,11 +963,6 @@ class WebhookHandler < Goliath::API # TODO: make prettier: this should be done above others_num = params['_json'][0]['to'] when 'message-delivered' - # TODO: remove this hack - if jparams['to'].length > 1 - puts "WARN! group no rcpt: #{users_num}" - return [200, {}, "OK"] - end msg = ReceiptMessage.new(bare_jid)