From f5ad5199aeaa020e0d6a723341cd578a53c10850 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 29 Jan 2021 12:05:01 +0100 Subject: Use async properly on session start --- poezio/core/handlers.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'poezio/core/handlers.py') diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index a388c5d6..1d5dcffe 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -79,27 +79,26 @@ class HandlerCore: def __init__(self, core): self.core = core - def on_session_start_features(self, _): + async def on_session_start_features(self, _): """ Enable carbons & blocking on session start if wanted and possible """ - def callback(iq): - if not iq: - return - features = iq['disco_info']['features'] - rostertab = self.core.tabs.by_name_and_class( - 'Roster', tabs.RosterInfoTab) - rostertab.check_blocking(features) - rostertab.check_saslexternal(features) - self.core.check_blocking(features) - if (config.get('enable_carbons') - and 'urn:xmpp:carbons:2' in features): - self.core.xmpp.plugin['xep_0280'].enable() - self.core.check_bookmark_storage(features) - - self.core.xmpp.plugin['xep_0030'].get_info( - jid=self.core.xmpp.boundjid.domain, callback=callback) + + iq = await self.core.xmpp.plugin['xep_0030'].get_info( + jid=self.core.xmpp.boundjid.domain + ) + features = iq['disco_info']['features'] + + rostertab = self.core.tabs.by_name_and_class( + 'Roster', tabs.RosterInfoTab) + rostertab.check_saslexternal(features) + rostertab.check_blocking(features) + self.core.check_blocking(features) + if (config.get('enable_carbons') + and 'urn:xmpp:carbons:2' in features): + self.core.xmpp.plugin['xep_0280'].enable() + await self.core.check_bookmark_storage(features) def find_identities(self, _): asyncio.ensure_future( @@ -1348,7 +1347,7 @@ class HandlerCore: pres.send() self.core.bookmarks.get_local() # join all the available bookmarks. As of yet, this is just the local ones - self.core.join_initial_rooms(self.core.bookmarks) + self.core.join_initial_rooms(self.core.bookmarks.local()) if config.get('enable_user_nick'): self.core.xmpp.plugin['xep_0172'].publish_nick( -- cgit v1.2.3