From 2455d00d59dd46f93f85039fa1e83f30092b376c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 30 Jan 2019 23:11:09 +0100 Subject: [PATCH] xep_0384: Add allow_untrusted parameter to decrypt_message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugin.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index b779068..25559ca 100644 --- a/plugin.py +++ b/plugin.py @@ -303,7 +303,7 @@ class XEP_0384(BasePlugin): def is_encrypted(self, msg: Message) -> bool: return msg.xml.find('{%s}encrypted' % OMEMO_BASE_NS) is not None - def decrypt_message(self, msg: Message) -> Optional[str]: + def decrypt_message(self, msg: Message, allow_untrusted: bool = False) -> Optional[str]: header = msg['omemo_encrypted']['header'] payload = b64dec(msg['omemo_encrypted']['payload']['value']) @@ -330,6 +330,7 @@ class XEP_0384(BasePlugin): message, isPrekeyMessage, payload, + allow_untrusted=allow_untrusted, ) return body except (omemo.exceptions.NoSessionException,): @@ -389,9 +390,7 @@ class XEP_0384(BasePlugin): devices = bundles.setdefault(exn.bare_jid, {}) devices[exn.device] = bundle elif isinstance(exn, omemo.exceptions.UntrustedException): - # TODO: Pass the exception down to the lib user - # raise UntrustedException(exn.bare_jid, exn.device, exn.ik) - self._omemo.trust(exn.bare_jid, exn.device, exn.ik) + raise UntrustedException(exn.bare_jid, exn.device, exn.ik) elif isinstance(exn, omemo.exceptions.NoEligibleDevicesException): # This error is returned by the library to specify that # encryption is not possible to any device of a user.