gateway: parse v7 rcvMsgContent shape and profile display name
Inbound DMs were silently dropped: simplex-chat v7 tags received text as
{"type": "rcvMsgContent", "msgContent": {"type": "text", ...}}, but
_parse_chat_item required a flat {"type": "text", "text": ...}. Every
message returned None (no gateway_message/gateway_sent/denied ever fired) so
pepper got no reply.
- parse content.msgContent.text, tolerating the DB/Aeson constructor-keyed
nesting as well
- resolve the peer name from profile.displayName first; v7's contact
displayName is null and localDisplayName is collision-suffixed (pepper_1)
- update the synthetic fixture to the real wire shape and add regression tests
- set PYTHONUNBUFFERED=1 in the rendered gateway unit so journal logging is live
This commit is contained in:
1 parent
5f05c5c749
commit
b348f19486
3 files changed
+84
-5
No files matched your search
@@ -161,14 +161,33 @@ class SimplexAdapter(GatewayAdapter):
|
||||
if direction and "Snd" in direction:
|
||||
return None # own echo
|
||||
content = chat_item.get("content") or {}
|
||||
if content.get("type") != "text":
|
||||
# simplex-chat v7 tags the content union by constructor: a received text
|
||||
# message is {"type": "rcvMsgContent", "msgContent": {"type": "text",
|
||||
# "text": ...}}. The daemon's DB/Aeson encoding nests under the
|
||||
# constructor key instead ({"rcvMsgContent": {"msgContent": ...}}), so
|
||||
# accept both shapes.
|
||||
if content.get("type") == "rcvMsgContent":
|
||||
msg_content = content.get("msgContent") or {}
|
||||
elif isinstance(content.get("rcvMsgContent"), dict):
|
||||
msg_content = content["rcvMsgContent"].get("msgContent") or {}
|
||||
else:
|
||||
return None
|
||||
text = str(content.get("text", "")).strip()
|
||||
if msg_content.get("type") != "text":
|
||||
return None
|
||||
text = str(msg_content.get("text", "")).strip()
|
||||
if not text:
|
||||
return None
|
||||
contact = chat_info.get("contact") or {}
|
||||
contact_id = str(contact.get("contactId") or chat_info.get("chatId") or "")
|
||||
display_name = contact.get("displayName") or contact.get("localDisplayName")
|
||||
profile = contact.get("profile") or {}
|
||||
# v7's Contact has `displayName: null`; the real peer name lives in
|
||||
# `profile.displayName`, and `localDisplayName` is auto-suffixed on
|
||||
# collisions (e.g. a second contact becomes `pepper_1`).
|
||||
display_name = (
|
||||
profile.get("displayName")
|
||||
or contact.get("displayName")
|
||||
or contact.get("localDisplayName")
|
||||
)
|
||||
if not contact_id:
|
||||
return None
|
||||
if not self.is_authorized(contact_id, display_name):
|
||||
|
||||
Reference in new issue
Block a user