From cbf212cab0623ab719433fe8da4288708a023204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sat, 28 Dec 2019 22:26:10 +0100 Subject: [PATCH] Remove handling for UndecidedException and UntrustedException as we always force decrypting even if untrusted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio_plugins/omemo/__init__.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/poezio_plugins/omemo/__init__.py b/poezio_plugins/omemo/__init__.py index 2ba9c2b..24acfc9 100644 --- a/poezio_plugins/omemo/__init__.py +++ b/poezio_plugins/omemo/__init__.py @@ -94,13 +94,18 @@ class Plugin(E2EEPlugin): if trust is not None ] - def decrypt(self, message: Message, tab, allow_untrusted=False) -> None: + def decrypt(self, message: Message, tab) -> None: body = None try: mfrom = message['from'] encrypted = message['omemo_encrypted'] - body = self.core.xmpp['xep_0384'].decrypt_message(encrypted, mfrom, allow_untrusted) + body = self.core.xmpp['xep_0384'].decrypt_message( + encrypted, + mfrom, + # Always decrypt. Let us handle how we then warn the user. + allow_untrusted=True, + ) body = body.decode('utf-8') except (MissingOwnKey,): # The message is missing our own key, it was not encrypted for @@ -119,20 +124,6 @@ class Plugin(E2EEPlugin): 'I can\'t decrypt this message as it uses an encrypted ' 'session I don\'t know about.', ) - except (UndecidedException, UntrustedException) as exn: - # We received a message from an untrusted device. We can - # choose to decrypt the message nonetheless, with the - # `allow_untrusted` flag on the `decrypt_message` call, which - # we will do here. This is only possible for decryption, - # encryption will require us to decide if we trust the device - # or not. Clients _should_ indicate that the message was not - # trusted, or in undecided state, if they decide to decrypt it - # anyway. - self.display_error( - "Your device '%s' is not in my trusted devices." % exn.device, - ) - # We resend, setting the `allow_untrusted` parameter to True. - self.decrypt(message, tab, allow_untrusted=True) except (EncryptionPrepareException,): # Slixmpp tried its best, but there were errors it couldn't # resolve. At this point you should have seen other exceptions