From b30501f004eed34b2c16c704509d30e3ef506958 Mon Sep 17 00:00:00 2001 From: souliane Date: Thu, 11 Sep 2014 15:38:57 +0200 Subject: [PATCH] plugin XEP-0033: fixes sending the message after the changes made in rev 1052 (e88bff4c8b77) --- src/plugins/plugin_xep_0033.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/plugin_xep_0033.py b/src/plugins/plugin_xep_0033.py index a9771840..d456c9fe 100644 --- a/src/plugins/plugin_xep_0033.py +++ b/src/plugins/plugin_xep_0033.py @@ -119,6 +119,16 @@ class XEP_0033(object): - redesign the database to save only one entry to the database - change the newMessage signal to eventually pass more than one recipient """ + def send(mess_data, skip_send=False): + client = self.host.profiles[profile] + d = defer.Deferred() + if not skip_send: + d.addCallback(self.host._sendMessageToStream, client) + d.addCallback(self.host._storeMessage, client) + d.addCallback(self.host.sendMessageToBridge, client) + d.addErrback(lambda failure: failure.trap(exceptions.CancelError)) + return d.callback(mess_data) + def discoCallback(entities, to_jid_s): history_data = copy.deepcopy(mess_data) history_data['to'] = JID(to_jid_s) @@ -128,13 +138,13 @@ class XEP_0033(object): sent_data = copy.deepcopy(mess_data) sent_data['to'] = JID(JID(to_jid_s).host) sent_data['xml']['to'] = JID(to_jid_s).host - self.host.sendAndStoreMessage(sent_data, False, profile) + send(sent_data) self.internal_data[timestamp].append(entities) # we still need to fill the history and signal the echo... - self.host.sendAndStoreMessage(history_data, True, profile) + send(history_data, skip_send=True) else: # target server misses the addressing feature - self.host.sendAndStoreMessage(history_data, False, profile) + send(history_data) def errback(failure, to_jid): discoCallback(None, to_jid)