From a106c8743d9b9a4227058986f097547d49a6968c Mon Sep 17 00:00:00 2001 From: Denver Gingerich Date: Mon, 27 Apr 2020 21:55:02 +0000 Subject: [PATCH] add support for message delivery failure notifying This is similar to the support for message delivery receipts themselves, so it's actually just as simple as checking for the correct 'type', and the importing the two hacks that we already have for message delivery receipts, namely those in b277759 and d49bf12 - we probably want to move them into a common area eventually, but this is fine for now, and definitely works in our tests just now. --- sgx-bwmsgsv2.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 4a960beb4a9b79414124c03cc2645ee45914af9d..5d5e35a433c5b53351549f0539c4b520d2d744a4 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -939,20 +939,28 @@ class WebhookHandler < Goliath::API resourcepart = WEBrick::HTTPUtils.unescape(tag_parts[1]) case type - when 'not-delivered' - # TODO: update above label + when 'message-failed' # create a bare message like the one user sent msg = Blather::Stanza::Message.new( others_num + '@' + ARGV[0]) 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 + # create an error reply to the bare message msg = Blather::StanzaError.new( msg, 'recipient-unavailable', :wait ).to_node + + # 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