fix: preserve NUL characters in persisted messages
Store message text as UTF-8 bytes and migrate existing rows without loss. Cover HTTP round trips, restart persistence, Unicode limits and idempotent retries. Adapt direct database tools to the binary storage format. (cherry picked from commit 386276532730b8758298080b49db63738ca300a4)
This commit is contained in:
+2
-2
@@ -78,7 +78,7 @@ def chat_view(row: dict) -> dict:
|
||||
def message_view(row: dict) -> dict:
|
||||
return {
|
||||
"id": str(row["id"]), "chat_id": str(row["chat_id"]),
|
||||
"sender_id": str(row["sender_id"]), "text": row["text"],
|
||||
"sender_id": str(row["sender_id"]), "text": row["text"].decode("utf-8"),
|
||||
"created_at": timestamp(row["created_at"]),
|
||||
"attachment_ids": [str(attachment_id) for attachment_id in row.get("attachment_ids", [])],
|
||||
}
|
||||
@@ -259,7 +259,7 @@ class Store:
|
||||
row = conn.execute(
|
||||
"INSERT INTO messages (id,chat_id,sender_id,text) VALUES (%s,%s,%s,%s) "
|
||||
"RETURNING id,chat_id,sender_id,text,created_at",
|
||||
(uuid4(), chat_uuid, actor_uuid, text),
|
||||
(uuid4(), chat_uuid, actor_uuid, text.encode("utf-8")),
|
||||
).fetchone()
|
||||
for position, attachment_id in enumerate(ids):
|
||||
conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user