From 1200dceb4c661975c96dd12faab46e1fe64a94ed Mon Sep 17 00:00:00 2001 From: geemili Date: Wed, 26 Feb 2025 13:08:01 -0700 Subject: [PATCH] check if the decoded messages are bytes or strings --- LXMF/LXMessage.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/LXMF/LXMessage.py b/LXMF/LXMessage.py index 515ab11..a81c051 100644 --- a/LXMF/LXMessage.py +++ b/LXMF/LXMessage.py @@ -757,8 +757,16 @@ class LXMessage: message.timestamp = timestamp message.packed = lxmf_bytes message.packed_size = len(lxmf_bytes) - message.set_title_from_bytes(title_bytes) - message.set_content_from_bytes(content_bytes) + + if type(title_bytes) is bytes: + message.set_title_from_bytes(title_bytes) + elif type(title_bytes) is str: + message.set_title_from_string(title_bytes) + + if type(content_bytes) is bytes: + message.set_content_from_bytes(content_bytes) + elif type(content_bytes) is str: + message.set_content_from_string(content_bytes) try: if source: @@ -795,4 +803,4 @@ class LXMessage: return lxm except Exception as e: RNS.log("Could not unpack LXMessage from file. The contained exception was: "+str(e), RNS.LOG_ERROR) - return None \ No newline at end of file + return None