Commit 03499a2d authored by Maxime Buquet's avatar Maxime Buquet

omemo: handle MissingBundleException when it comes from EncryptionPrepareException

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 Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent 0e27485c
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment