delivery receipts: remove some duplicate hack code

Denver Gingerich created

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.

Change summary

sgx-bwmsgsv2.rb | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)

Detailed changes

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)