comparison sat/plugins/plugin_xep_0045.py @ 3541:888109774673

core: various changes and fixes to work with new storage and D-Bus bridge: - fixes coroutines handling in various places - fixes types which are not serialised by Tx DBus - XEP-0384: call storage methods in main thread in XEP: Python OMEMO's Promise use thread which prevent the use of AsyncIO loop. To work around that, callLater is used to launch storage method in main thread. This is a temporary workaround, as Python OMEMO should get rid of Promise implementation and threads soon.
author Goffi <goffi@goffi.org>
date Thu, 03 Jun 2021 15:21:43 +0200
parents be6d91572633
children 813595f88612
comparison
equal deleted inserted replaced
3540:aa58451b77ba 3541:888109774673
835 room_jid = mess_data["to"] 835 room_jid = mess_data["to"]
836 service = jid.JID(room_jid.host) 836 service = jid.JID(room_jid.host)
837 elif client.muc_service is not None: 837 elif client.muc_service is not None:
838 service = client.muc_service 838 service = client.muc_service
839 else: 839 else:
840 msg = D_("No known default MUC service".format(unparsed)) 840 msg = D_("No known default MUC service {unparsed}").format(
841 unparsed=unparsed)
841 self.text_cmds.feedBack(client, msg, mess_data) 842 self.text_cmds.feedBack(client, msg, mess_data)
842 return False 843 return False
843 except jid.InvalidFormat: 844 except jid.InvalidFormat:
844 msg = D_("{} is not a valid JID!".format(unparsed)) 845 msg = D_("{} is not a valid JID!".format(unparsed))
845 self.text_cmds.feedBack(client, msg, mess_data) 846 self.text_cmds.feedBack(client, msg, mess_data)
1296 # it attached to the element 1297 # it attached to the element
1297 mess_data = message.element._mess_data 1298 mess_data = message.element._mess_data
1298 except AttributeError: 1299 except AttributeError:
1299 mess_data = self.client.messageProt.parseMessage(message.element) 1300 mess_data = self.client.messageProt.parseMessage(message.element)
1300 if mess_data['message'] or mess_data['subject']: 1301 if mess_data['message'] or mess_data['subject']:
1301 return self.host.memory.addToHistory(self.client, mess_data) 1302 return defer.ensureDeferred(
1303 self.host.memory.addToHistory(self.client, mess_data)
1304 )
1302 else: 1305 else:
1303 return defer.succeed(None) 1306 return defer.succeed(None)
1304 1307
1305 def _addToHistoryEb(self, failure): 1308 def _addToHistoryEb(self, failure):
1306 failure.trap(exceptions.CancelError) 1309 failure.trap(exceptions.CancelError)