From 32b24604d83d12af648ae78c82537ef44b01aeae Mon Sep 17 00:00:00 2001 From: tek Date: Fri, 26 Apr 2024 13:13:15 +0200 Subject: [PATCH] Fixes datetime issues in iOS SMS parsing --- mvt/ios/modules/mixed/sms.py | 4 +++- mvt/ios/modules/mixed/sms_attachments.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mvt/ios/modules/mixed/sms.py b/mvt/ios/modules/mixed/sms.py index e5b744b..5f711da 100644 --- a/mvt/ios/modules/mixed/sms.py +++ b/mvt/ios/modules/mixed/sms.py @@ -144,7 +144,9 @@ class SMS(IOSExtraction): # We convert Mac's ridiculous timestamp format. message["isodate"] = convert_mactime_to_iso(message["date"]) - message["isodate_read"] = convert_mactime_to_iso(message["date_read"]) + if message["date_read"]: + message["isodate_read"] = convert_mactime_to_iso(message["date_read"]) + message["direction"] = ( "sent" if message.get("is_from_me", 0) == 1 else "received" ) diff --git a/mvt/ios/modules/mixed/sms_attachments.py b/mvt/ios/modules/mixed/sms_attachments.py index ea9b477..57b4a92 100644 --- a/mvt/ios/modules/mixed/sms_attachments.py +++ b/mvt/ios/modules/mixed/sms_attachments.py @@ -112,8 +112,15 @@ class SMSAttachments(IOSExtraction): value = b64encode(value).decode() attachment[names[index]] = value - attachment["isodate"] = convert_mactime_to_iso(attachment["created_date"]) - attachment["start_date"] = convert_mactime_to_iso(attachment["start_date"]) + if attachment["created_date"]: + attachment["isodate"] = convert_mactime_to_iso( + attachment["created_date"] + ) + if attachment["start_date"]: + attachment["start_date"] = convert_mactime_to_iso( + attachment["start_date"] + ) + attachment["direction"] = ( "sent" if attachment["is_outgoing"] == 1 else "received" )