From cbe96a6f77e54fc0c4c40d1e81faab29c9de3946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Fri, 23 Aug 2019 11:27:28 +0200 Subject: omemo: Skip devices on MissingBundleException. Encrypt to the rest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugins/omemo_plugin.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/omemo_plugin.py b/plugins/omemo_plugin.py index 6ef104ba..c676267a 100644 --- a/plugins/omemo_plugin.py +++ b/plugins/omemo_plugin.py @@ -15,6 +15,7 @@ import logging from poezio.plugin_e2ee import E2EEPlugin from poezio.xdg import DATA_HOME +from omemo.exceptions import MissingBundleException from slixmpp.stanza import Message from slixmpp_omemo import PluginCouldNotLoad, MissingOwnKey, NoAvailableSession from slixmpp_omemo import UndecidedException, UntrustedException, EncryptionPrepareException @@ -111,6 +112,7 @@ class Plugin(E2EEPlugin): mto = message['to'] mtype = message['type'] body = message['body'] + expect_problems = {} # type: Optional[Dict[JID, List[int]]] while True: try: @@ -126,7 +128,7 @@ class Plugin(E2EEPlugin): # TODO: Document expect_problems # TODO: Handle multiple recipients (MUCs) recipients = [mto] - encrypt = await self.core.xmpp['xep_0384'].encrypt_message(body, recipients) + encrypt = await self.core.xmpp['xep_0384'].encrypt_message(body, recipients, expect_problems) message.append(encrypt) return None except UndecidedException as exn: @@ -136,6 +138,12 @@ class Plugin(E2EEPlugin): # this bot we will automatically trust undecided recipients. self.core.xmpp['xep_0384'].trust(exn.bare_jid, exn.device, exn.ik) # TODO: catch NoEligibleDevicesException and MissingBundleException + 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) except Exception as exn: self.display_error( 'An error occured while attempting to encrypt.\n%r' % exn, -- cgit v1.2.3