Don't fail on decrypting heartbeats
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
494899bb3c
commit
05b5705f22
1 changed files with 24 additions and 12 deletions
|
@ -650,9 +650,10 @@ class XEP_0384(BasePlugin):
|
|||
allow_untrusted: bool = False,
|
||||
) -> Optional[str]:
|
||||
header = encrypted['header']
|
||||
if encrypted['payload']['value'] is None:
|
||||
raise ErroneousPayload('The payload element was empty')
|
||||
payload = b64dec(encrypted['payload']['value'])
|
||||
|
||||
payload = None
|
||||
if encrypted['payload']['value'] is not None:
|
||||
payload = b64dec(encrypted['payload']['value'])
|
||||
|
||||
jid = sender.bare
|
||||
sid = int(header['sid'])
|
||||
|
@ -674,15 +675,26 @@ class XEP_0384(BasePlugin):
|
|||
# XXX: 'cipher' is part of KeyTransportMessages and is used when no payload
|
||||
# is passed. We do not implement this yet.
|
||||
try:
|
||||
body = self._omemo.decryptMessage(
|
||||
jid,
|
||||
sid,
|
||||
iv,
|
||||
message,
|
||||
isPrekeyMessage,
|
||||
payload,
|
||||
allow_untrusted=allow_untrusted,
|
||||
)
|
||||
if payload is None:
|
||||
self._omemo.decryptRatchetFowardingMessage(
|
||||
jid,
|
||||
sid,
|
||||
iv,
|
||||
message,
|
||||
isPrekeyMessage,
|
||||
allow_untrusted=allow_untrusted,
|
||||
)
|
||||
body = None
|
||||
else:
|
||||
body = self._omemo.decryptMessage(
|
||||
jid,
|
||||
sid,
|
||||
iv,
|
||||
message,
|
||||
isPrekeyMessage,
|
||||
payload,
|
||||
allow_untrusted=allow_untrusted,
|
||||
)
|
||||
except (omemo.exceptions.NoSessionException,):
|
||||
# This might happen when the sender is sending using a session
|
||||
# that we don't know about (deleted session storage, etc.). In
|
||||
|
|
Loading…
Reference in a new issue