comparison 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
comparison
equal deleted inserted replaced
3912:ce5d03772689 3913:944f51f9c2b4
153 client = self.host.getClient(profile) 153 client = self.host.getClient(profile)
154 154
155 def send(mess_data, skip_send=False): 155 def send(mess_data, skip_send=False):
156 d = defer.Deferred() 156 d = defer.Deferred()
157 if not skip_send: 157 if not skip_send:
158 d.addCallback(client.sendMessageData) 158 d.addCallback(
159 lambda ret: defer.ensureDeferred(client.sendMessageData(ret))
160 )
159 d.addCallback( 161 d.addCallback(
160 lambda ret: defer.ensureDeferred(client.messageAddToHistory(ret)) 162 lambda ret: defer.ensureDeferred(client.messageAddToHistory(ret))
161 ) 163 )
162 d.addCallback(client.messageSendToBridge) 164 d.addCallback(client.messageSendToBridge)
163 d.addErrback(lambda failure: failure.trap(exceptions.CancelError)) 165 d.addErrback(lambda failure: failure.trap(exceptions.CancelError))