Fix Signal compose live updates and self-chat direction
This commit is contained in:
@@ -129,7 +129,36 @@ def _format_ts_label(ts_value: int) -> str:
|
||||
|
||||
|
||||
def _is_outgoing(msg: Message) -> bool:
|
||||
return str(msg.custom_author or "").upper() in {"USER", "BOT"}
|
||||
is_outgoing = str(msg.custom_author or "").upper() in {"USER", "BOT"}
|
||||
if not is_outgoing:
|
||||
return False
|
||||
|
||||
# Signal self-chat special case:
|
||||
# platform-originated Signal sync events can carry our own sender id and
|
||||
# are currently stored as USER; render them as counterpart-side so the
|
||||
# thread reads naturally when messaging ourselves.
|
||||
try:
|
||||
session = getattr(msg, "session", None)
|
||||
identifier_obj = getattr(session, "identifier", None)
|
||||
service = str(getattr(identifier_obj, "service", "") or "").strip().lower()
|
||||
if service != "signal":
|
||||
return True
|
||||
|
||||
sender_uuid = str(getattr(msg, "sender_uuid", "") or "").strip()
|
||||
identifier_value = str(getattr(identifier_obj, "identifier", "") or "").strip()
|
||||
if not sender_uuid or not identifier_value:
|
||||
return True
|
||||
|
||||
if sender_uuid.lower() == identifier_value.lower():
|
||||
return False
|
||||
sender_digits = re.sub(r"[^0-9]", "", sender_uuid)
|
||||
identifier_digits = re.sub(r"[^0-9]", "", identifier_value)
|
||||
if sender_digits and identifier_digits and sender_digits == identifier_digits:
|
||||
return False
|
||||
except Exception:
|
||||
return is_outgoing
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def _clean_url(candidate: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user