Echo_bot: prevent loops when decrypting/encrypting

Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <>
parent 79a4f417
......@@ -88,6 +88,7 @@ class EchoBot(ClientXMPP):
encrypted = msg['omemo_encrypted']
body = self['xep_0384'].decrypt_message(encrypted, mfrom, allow_untrusted)
await self.encrypted_reply(msg, 'Thanks for sending\n%s' % body.decode("utf8"))
return None
except (MissingOwnKey,):
# The message is missing our own key, it was not encrypted for
# us, and we can't decrypt it.
......@@ -95,6 +96,7 @@ class EchoBot(ClientXMPP):
'I can\'t decrypt this message as it is not encrypted for me.',
return None
except (NoAvailableSession,) as exn:
# We received a message from that contained a session that we
# don't know about (deleted session storage, etc.). We can't
......@@ -107,6 +109,7 @@ class EchoBot(ClientXMPP):
'I can\'t decrypt this message as it uses an encrypted '
'session I don\'t know about.',
return None
except (UndecidedException, UntrustedException) as exn:
# We received a message from an untrusted device. We can
# choose to decrypt the message nonetheless, with the
......@@ -122,11 +125,13 @@ class EchoBot(ClientXMPP):
# We resend, setting the `allow_untrusted` parameter to True.
await self.message(msg, allow_untrusted=True)
return None
except (EncryptionPrepareException,):
# Slixmpp tried its best, but there were errors it couldn't
# resolve. At this point you should have seen other exceptions
# and given a chance to resolve them already.
await self.plain_reply(msg, 'I was not able to decrypt the message.')
return None
except (Exception,) as exn:
await self.plain_reply(msg, 'An error occured while attempting decryption.\n%r' % exn)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment