WIP: Fix non-awaited task
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
c16d3f1cd9
commit
26fbb7e28c
1 changed files with 4 additions and 6 deletions
|
@ -236,7 +236,6 @@ class XEP_0384(BasePlugin):
|
||||||
"no data directory specified.")
|
"no data directory specified.")
|
||||||
|
|
||||||
self._device_id = _load_device_id(self.data_dir)
|
self._device_id = _load_device_id(self.data_dir)
|
||||||
asyncio.create_task(self.session_start_omemo())
|
|
||||||
|
|
||||||
self.xmpp.add_event_handler('session_start', self.session_start)
|
self.xmpp.add_event_handler('session_start', self.session_start)
|
||||||
self.xmpp['xep_0060'].map_node_event(OMEMO_DEVICES_NS, 'omemo_device_list')
|
self.xmpp['xep_0060'].map_node_event(OMEMO_DEVICES_NS, 'omemo_device_list')
|
||||||
|
@ -245,7 +244,7 @@ class XEP_0384(BasePlugin):
|
||||||
# If this plugin is loaded after 'session_start' has fired, we still
|
# If this plugin is loaded after 'session_start' has fired, we still
|
||||||
# need to publish bundles
|
# need to publish bundles
|
||||||
if self.xmpp.is_connected and not self._initial_publish_done:
|
if self.xmpp.is_connected and not self._initial_publish_done:
|
||||||
asyncio.create_task(self._initial_publish())
|
asyncio.ensure_future(self.session_start(None))
|
||||||
|
|
||||||
def plugin_end(self):
|
def plugin_end(self):
|
||||||
if not self.backend_loaded:
|
if not self.backend_loaded:
|
||||||
|
@ -255,7 +254,7 @@ class XEP_0384(BasePlugin):
|
||||||
self.xmpp.remove_event_handler('omemo_device_list_publish', self._receive_device_list)
|
self.xmpp.remove_event_handler('omemo_device_list_publish', self._receive_device_list)
|
||||||
self.xmpp['xep_0163'].remove_interest(OMEMO_DEVICES_NS)
|
self.xmpp['xep_0163'].remove_interest(OMEMO_DEVICES_NS)
|
||||||
|
|
||||||
async def session_start_omemo(self):
|
async def session_start(self, _jid):
|
||||||
"""Creates the OMEMO session object"""
|
"""Creates the OMEMO session object"""
|
||||||
|
|
||||||
storage = self.storage_backend
|
storage = self.storage_backend
|
||||||
|
@ -277,15 +276,14 @@ class XEP_0384(BasePlugin):
|
||||||
log.error("Couldn't load the OMEMO object; ¯\\_(ツ)_/¯")
|
log.error("Couldn't load the OMEMO object; ¯\\_(ツ)_/¯")
|
||||||
raise PluginCouldNotLoad from exn
|
raise PluginCouldNotLoad from exn
|
||||||
|
|
||||||
|
await self._initial_publish()
|
||||||
|
|
||||||
def _omemo(self) -> SessionManager:
|
def _omemo(self) -> SessionManager:
|
||||||
"""Helper method to unguard potentially uninitialized SessionManager"""
|
"""Helper method to unguard potentially uninitialized SessionManager"""
|
||||||
if self.__omemo_session is None:
|
if self.__omemo_session is None:
|
||||||
raise UninitializedOMEMOSession
|
raise UninitializedOMEMOSession
|
||||||
return self.__omemo_session
|
return self.__omemo_session
|
||||||
|
|
||||||
async def session_start(self, _jid):
|
|
||||||
await self._initial_publish()
|
|
||||||
|
|
||||||
async def _initial_publish(self):
|
async def _initial_publish(self):
|
||||||
if self.backend_loaded:
|
if self.backend_loaded:
|
||||||
self.xmpp['xep_0163'].add_interest(OMEMO_DEVICES_NS)
|
self.xmpp['xep_0163'].add_interest(OMEMO_DEVICES_NS)
|
||||||
|
|
Loading…
Reference in a new issue