From 74bc166b884f1ef51df54d0baff2524a50e0a925 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 28 Apr 2019 08:55:07 +0200 Subject: [PATCH] plugin XEP-0384: wait for client to be ready if session is missing when onNewDevices is called --- sat/plugins/plugin_xep_0384.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sat/plugins/plugin_xep_0384.py b/sat/plugins/plugin_xep_0384.py index 689ef149..f7b60817 100644 --- a/sat/plugins/plugin_xep_0384.py +++ b/sat/plugins/plugin_xep_0384.py @@ -539,6 +539,8 @@ class OMEMO(object): @defer.inlineCallbacks def profileConnected(self, client): + # FIXME: is _xep_0384_ready needed? can we use profileConnecting? + # Workflow should be checked client._xep_0384_ready = defer.Deferred() # we first need to get devices ids (including our own) persistent_dict = persistent.LazyPersistentBinaryDict("XEP-0384", client.profile) @@ -767,7 +769,11 @@ class OMEMO(object): @defer.inlineCallbacks def onNewDevices(self, itemsEvent, profile): client = self.host.getClient(profile) - omemo_session = client._xep_0384_session + try: + omemo_session = client._xep_0384_session + except AttributeError: + yield client._xep_0384_ready + omemo_session = client._xep_0384_session entity = itemsEvent.sender devices = self.parseDevices(itemsEvent.items)