From 03499a2d2c0a657a886913d3988d69ca08ceca3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 25 Aug 2019 00:48:57 +0200 Subject: omemo: handle MissingBundleException when it comes from EncryptionPrepareException MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're not supposed to see MissingBundleException directly as it's handled by slixmpp-omemo. Slixmpp-omemo will give us all the remaining exceptions via EncryptionPrepareException when it doesn't know what to do anymore. Signed-off-by: Maxime “pep” Buquet --- plugins/omemo_plugin.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/omemo_plugin.py b/plugins/omemo_plugin.py index 6efa8c08..538be98e 100644 --- a/plugins/omemo_plugin.py +++ b/plugins/omemo_plugin.py @@ -18,6 +18,7 @@ from poezio.xdg import DATA_HOME from poezio.tabs import DynamicConversationTab, StaticConversationTab, MucTab from omemo.exceptions import MissingBundleException +from slixmpp import JID from slixmpp.stanza import Message from slixmpp.exceptions import IqError, IqTimeout from slixmpp_omemo import PluginCouldNotLoad, MissingOwnKey, NoAvailableSession @@ -143,13 +144,18 @@ class Plugin(E2EEPlugin): # This is where you prompt your user to ask what to do. In # this bot we will automatically trust undecided recipients. self.core.xmpp['xep_0384'].trust(exn.bare_jid, exn.device, exn.ik) - except MissingBundleException as exn: - self.display_error( - 'Could not find keys for device "%d" of recipient "%s". Skipping.' % (exn.device, exn.bare_jid), - ) - device_list = expect_problems.setdefault(exn.bare_jid, []) - device_list.append(exn.device) # TODO: catch NoEligibleDevicesException + except EncryptionPrepareException as exn: + log.debug('FOO: EncryptionPrepareException: %r', exn.errors) + for error in exn.errors: + if isinstance(error, MissingBundleException): + self.display_error( + 'Could not find keys for device "%d" of recipient "%s". Skipping.' % + (error.device, error.bare_jid), + ) + jid = JID(error.bare_jid) + device_list = expect_problems.setdefault(jid, []) + device_list.append(error.device) except (IqError, IqTimeout) as exn: self.display_error( 'An error occured while fetching information on a recipient.\n%r' % exn, -- cgit v1.2.3