Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0297.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 | be6d91572633 |
children | 524856bd7b19 |
comparison
equal
deleted
inserted
replaced
3912:ce5d03772689 | 3913:944f51f9c2b4 |
---|---|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | 20 |
21 from sat.core.constants import Const as C | 21 from sat.core.constants import Const as C |
22 from sat.core.i18n import _, D_ | 22 from sat.core.i18n import _, D_ |
23 from sat.core.log import getLogger | 23 from sat.core.log import getLogger |
24 | |
25 from twisted.internet import defer | |
24 | 26 |
25 log = getLogger(__name__) | 27 log = getLogger(__name__) |
26 | 28 |
27 from wokkel import disco, iwokkel | 29 from wokkel import disco, iwokkel |
28 | 30 |
102 | 104 |
103 msg.addChild(body_elt) | 105 msg.addChild(body_elt) |
104 msg.addChild(forwarded_elt) | 106 msg.addChild(forwarded_elt) |
105 | 107 |
106 client = self.host.getClient(profile_key) | 108 client = self.host.getClient(profile_key) |
107 return client.sendMessageData({"xml": msg}) | 109 return defer.ensureDeferred(client.sendMessageData({"xml": msg})) |
108 | 110 |
109 | 111 |
110 @implementer(iwokkel.IDisco) | 112 @implementer(iwokkel.IDisco) |
111 class XEP_0297_handler(XMPPHandler): | 113 class XEP_0297_handler(XMPPHandler): |
112 | 114 |