From bd2f063cc02e7eb742b851cc879f359b9abb5a04 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Sat, 12 Aug 2023 15:51:05 +0800 Subject: [PATCH] Bug fix on calls without chat #58 --- Whatsapp_Chat_Exporter/extract.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Whatsapp_Chat_Exporter/extract.py b/Whatsapp_Chat_Exporter/extract.py index 49b6c25..6441eff 100644 --- a/Whatsapp_Chat_Exporter/extract.py +++ b/Whatsapp_Chat_Exporter/extract.py @@ -593,10 +593,13 @@ def calls(db, data): video_call, duration, call_result, - bytes_transferred + bytes_transferred, + chat.subject as chat_subject FROM call_log INNER JOIN jid - ON call_log.jid_row_id = jid._id""" + ON call_log.jid_row_id = jid._id + LEFT JOIN chat + ON call_log.jid_row_id = chat.jid_row_id""" ) chat = ChatStore(Device.ANDROID, "WhatsApp Calls") content = c.fetchone() @@ -608,16 +611,17 @@ def calls(db, data): key_id=content["call_id"], ) _jid = content["raw_string"] - if _jid in data: - name = data[_jid].name - fallback = _jid.split('@')[0] if "@" in _jid else None - call.sender = name or fallback - + name = data[_jid].name if _jid in data else content["chat_subject"] or None + if _jid is not None and "@" in _jid: + fallback = _jid.split('@')[0] + else: + fallback = None + call.sender = name or fallback call.meta = True call.data = ( f"A {'video' if content['video_call'] else 'voice'} " f"call {'to' if call.from_me else 'from'} " - f"{name or fallback} was " + f"{call.sender} was " ) if content['call_result'] == 2: call.data += "not answered." if call.from_me else "missed."