diff sat/plugins/plugin_xep_0033.py @ 3913:944f51f9c2b4

core (xmpp): make `send` a blocking method, fix `sendMessageData` calls: original `send` method is blocking, and it is used as such by Wokkel and thus can't be changed to an async method easily. However, an Async method is necessary to have an async trigger at the very end of the send workflow for end-to-end encryption. To workaround that, `send` is an async method which call `a_send`, an async method which actually does the sending. This way legacy method can still call `send` while `a_send` can be await otherwise. Fix calls to `sendMessageData`: the method now being an `async` one, `ensureDeferred` had to be used in some calls.
author Goffi <goffi@goffi.org>
date Sat, 24 Sep 2022 16:31:39 +0200
parents 888109774673
children 524856bd7b19
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0033.py	Sat Sep 24 16:08:26 2022 +0200
+++ b/sat/plugins/plugin_xep_0033.py	Sat Sep 24 16:31:39 2022 +0200
@@ -155,7 +155,9 @@
         def send(mess_data, skip_send=False):
             d = defer.Deferred()
             if not skip_send:
-                d.addCallback(client.sendMessageData)
+                d.addCallback(
+                    lambda ret: defer.ensureDeferred(client.sendMessageData(ret))
+                )
             d.addCallback(
                 lambda ret: defer.ensureDeferred(client.messageAddToHistory(ret))
             )