Merge branch 'decrypt-heartbeats' into 'main'
Don't fail on decrypting heartbeats See merge request poezio/slixmpp-omemo!12
This commit is contained in:
commit
aa91f43aa0
2 changed files with 29 additions and 12 deletions
|
@ -150,6 +150,11 @@ class EchoBot(ClientXMPP):
|
|||
try:
|
||||
encrypted = msg['omemo_encrypted']
|
||||
body = self['xep_0384'].decrypt_message(encrypted, mfrom, allow_untrusted)
|
||||
# decrypt_message returns Optional[str]. It is possible to get
|
||||
# body-less OMEMO message (see KeyTransportMessages), currently
|
||||
# used for example to send heartbeats to other devices.
|
||||
if body is None:
|
||||
return None
|
||||
decoded = body.decode('utf8')
|
||||
if self.is_command(decoded):
|
||||
await self.handle_command(mto, mtype, decoded)
|
||||
|
|
|
@ -650,8 +650,9 @@ 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 = None
|
||||
if encrypted['payload']['value'] is not None:
|
||||
payload = b64dec(encrypted['payload']['value'])
|
||||
|
||||
jid = sender.bare
|
||||
|
@ -674,6 +675,17 @@ 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:
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue