fix(v2): Handle bytes expected_ack from meshcore + DM prefix matching

- Convert bytes to hex string for expected_ack and pkt_payload via _to_str()
- Support pubkey prefix matching in get_dm_messages() (LIKE for short keys)
- Fixes "Object of type bytes is not JSON serializable" error on DM view

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-01 13:36:37 +01:00
parent 752c60f02d
commit 95dcf38d06
2 changed files with 25 additions and 8 deletions
+10 -3
View File
@@ -291,13 +291,20 @@ class Database:
offset: int = 0) -> List[Dict]:
contact_pubkey = contact_pubkey.lower()
with self._connect() as conn:
# Support both full key and prefix matching
if len(contact_pubkey) < 64:
condition = "contact_pubkey LIKE ?"
param = contact_pubkey + '%'
else:
condition = "contact_pubkey = ?"
param = contact_pubkey
rows = conn.execute(
"""SELECT * FROM (
f"""SELECT * FROM (
SELECT * FROM direct_messages
WHERE contact_pubkey = ?
WHERE {condition}
ORDER BY timestamp DESC LIMIT ? OFFSET ?
) ORDER BY timestamp ASC""",
(contact_pubkey, limit, offset)
(param, limit, offset)
).fetchall()
return [dict(r) for r in rows]