Ignore messages with "None" for the content

This commit is contained in:
Erik Stambaugh 2025-07-13 10:29:50 -07:00
parent a9c0ad06ec
commit 5da2c725f1

View file

@ -69,27 +69,28 @@ def listen_for_notifications(host="signal-cli", port=7583):
source = envelope["source"] source = envelope["source"]
if "dataMessage" in envelope: if "dataMessage" in envelope:
msg = envelope["dataMessage"]["message"] # there are non-message messages, like read receipts msg = envelope["dataMessage"]["message"] # there are non-message messages, like read receipts
if "groupInfo" in envelope["dataMessage"]: if msg is not None:
group_id = envelope["dataMessage"]["groupInfo"]["groupId"] if "groupInfo" in envelope["dataMessage"]:
if group_id not in SIGNAL_GROUP_ALLOWLIST: group_id = envelope["dataMessage"]["groupInfo"]["groupId"]
print(f"GROUP RECV DENIED ({source}): {envelope}") if group_id not in SIGNAL_GROUP_ALLOWLIST:
break print(f"GROUP RECV DENIED ({source}): {envelope}")
print(f"GROUP ({group_id}/{source}): {msg}") break
params = { "recipient": group_id, "groupId": group_id } print(f"GROUP ({group_id}/{source}): {msg}")
else: params = { "recipient": group_id, "groupId": group_id }
if source not in SIGNAL_USER_ALLOWLIST: else:
print(f"RECV DENIED ({source}): {envelope}") if source not in SIGNAL_USER_ALLOWLIST:
break print(f"RECV DENIED ({source}): {envelope}")
break
print(f"RECV ({source}): {msg}") print(f"RECV ({source}): {msg}")
params = { "recipient": source } params = { "recipient": source }
params["message"] = process_message(msg) params["message"] = process_message(msg)
print("PARAMS:",params) print("PARAMS:",params)
result = send_json_rpc( result = send_json_rpc(
method="send", method="send",
params=params params=params
) )
except json.JSONDecodeError: except json.JSONDecodeError:
print("Invalid JSON:", line) print("Invalid JSON:", line)