Don't fail on decrypting heartbeats

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2021-12-14 17:20:16 +01:00
parent 494899bb3c
commit 05b5705f22
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -650,8 +650,9 @@ class XEP_0384(BasePlugin):
allow_untrusted: bool = False, allow_untrusted: bool = False,
) -> Optional[str]: ) -> Optional[str]:
header = encrypted['header'] header = encrypted['header']
if encrypted['payload']['value'] is None:
raise ErroneousPayload('The payload element was empty') payload = None
if encrypted['payload']['value'] is not None:
payload = b64dec(encrypted['payload']['value']) payload = b64dec(encrypted['payload']['value'])
jid = sender.bare jid = sender.bare
@ -674,6 +675,17 @@ class XEP_0384(BasePlugin):
# XXX: 'cipher' is part of KeyTransportMessages and is used when no payload # XXX: 'cipher' is part of KeyTransportMessages and is used when no payload
# is passed. We do not implement this yet. # is passed. We do not implement this yet.
try: try:
if payload is None:
self._omemo.decryptRatchetFowardingMessage(
jid,
sid,
iv,
message,
isPrekeyMessage,
allow_untrusted=allow_untrusted,
)
body = None
else:
body = self._omemo.decryptMessage( body = self._omemo.decryptMessage(
jid, jid,
sid, sid,