diff src/plugins/plugin_xep_0033.py @ 1205:3e234902177a

plugin XEP-0033: fixes sending the message after the changes made in rev 1052 (e88bff4c8b77)
author souliane <souliane@mailoo.org>
date Thu, 11 Sep 2014 15:38:57 +0200
parents e88bff4c8b77
children 0befb14ecf62
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0033.py	Mon Sep 15 14:18:34 2014 +0200
+++ b/src/plugins/plugin_xep_0033.py	Thu Sep 11 15:38:57 2014 +0200
@@ -119,6 +119,16 @@
         - 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 @@
                     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)