From 74fff8b7f89693dba57b742a976d2d6c297a6622 Mon Sep 17 00:00:00 2001 From: JJTech0130 Date: Mon, 31 Jul 2023 15:23:09 -0400 Subject: [PATCH] fix sender not displaing correctly --- imessage.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imessage.py b/imessage.py index 08c9476..c6f78ea 100644 --- a/imessage.py +++ b/imessage.py @@ -85,7 +85,7 @@ class iMessage: return True - def from_raw(message: bytes) -> "iMessage": + def from_raw(message: bytes, sender: str | None = None) -> "iMessage": """Create an `iMessage` from raw message bytes""" compressed = False try: @@ -100,7 +100,7 @@ class iMessage: text=message.get("t", ""), xml=message.get("x"), participants=message.get("p", []), - sender=message.get("p", [])[-1] if message.get("p", []) != [] else None, + sender=sender if sender is not None else message.get("p", [])[-1] if "p" in message else None, _id=uuid.UUID(message.get("r")) if "r" in message else None, group_id=uuid.UUID(message.get("gid")) if "gid" in message else None, body=BalloonBody(message["bid"], message["b"]) @@ -333,7 +333,7 @@ class iMessageUser: decrypted = self._decrypt_payload(payload) - return iMessage.from_raw(decrypted) + return iMessage.from_raw(decrypted, body['sP']) KEY_CACHE: dict[bytes, tuple[bytes, bytes]] = {} """Mapping of push token : (public key, session token)"""