Remove handling for UndecidedException and UntrustedException as we always force decrypting even if untrusted

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2019-12-28 22:26:10 +01:00
parent e412506a58
commit cbf212cab0
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -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