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:
parent
e412506a58
commit
cbf212cab0
1 changed files with 7 additions and 16 deletions
|
@ -94,13 +94,18 @@ class Plugin(E2EEPlugin):
|
||||||
if trust is not None
|
if trust is not None
|
||||||
]
|
]
|
||||||
|
|
||||||
def decrypt(self, message: Message, tab, allow_untrusted=False) -> None:
|
def decrypt(self, message: Message, tab) -> None:
|
||||||
|
|
||||||
body = None
|
body = None
|
||||||
try:
|
try:
|
||||||
mfrom = message['from']
|
mfrom = message['from']
|
||||||
encrypted = message['omemo_encrypted']
|
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')
|
body = body.decode('utf-8')
|
||||||
except (MissingOwnKey,):
|
except (MissingOwnKey,):
|
||||||
# The message is missing our own key, it was not encrypted for
|
# 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 '
|
'I can\'t decrypt this message as it uses an encrypted '
|
||||||
'session I don\'t know about.',
|
'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,):
|
except (EncryptionPrepareException,):
|
||||||
# Slixmpp tried its best, but there were errors it couldn't
|
# Slixmpp tried its best, but there were errors it couldn't
|
||||||
# resolve. At this point you should have seen other exceptions
|
# resolve. At this point you should have seen other exceptions
|
||||||
|
|
Loading…
Reference in a new issue