summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-08-23 11:27:28 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2019-12-27 18:57:33 +0100
commitcbe96a6f77e54fc0c4c40d1e81faab29c9de3946 (patch)
tree8fce90043639b89b5855c62b1f62e70daa017767 /plugins
parent687f360797248d80cc17d1311d03697d8773cd23 (diff)
downloadpoezio-cbe96a6f77e54fc0c4c40d1e81faab29c9de3946.tar.gz
poezio-cbe96a6f77e54fc0c4c40d1e81faab29c9de3946.tar.bz2
poezio-cbe96a6f77e54fc0c4c40d1e81faab29c9de3946.tar.xz
poezio-cbe96a6f77e54fc0c4c40d1e81faab29c9de3946.zip
omemo: Skip devices on MissingBundleException. Encrypt to the rest
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/omemo_plugin.py10
1 files changed, 9 insertions, 1 deletions
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,