Skip to content

Commit

Permalink
Apply review feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjambi committed Oct 7, 2023
1 parent 15f5dd4 commit d292d9d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions miio/protocol.py
Expand Up @@ -161,11 +161,9 @@ def _encode(self, obj, context, path):

def _decode(self, obj, context, path) -> Union[Dict, bytes]:
"""Decrypts the payload using the token stored in the context."""
# if there is no payload, decode to 0 bytes. Missing payload is expected for discovery messages.
# note that we don't have "token" in the context for discovery replies so we couldn't decode it
# anyway.
if obj == b"":
return b""
# Missing payload is expected for discovery messages.
if not obj:
return obj
try:
decrypted = Utils.decrypt(obj, context["_"]["token"])
decrypted = decrypted.rstrip(b"\x00")
Expand Down

0 comments on commit d292d9d

Please sign in to comment.