Commit d4eca36
Changed files (2)
src
history
src/history/turso.py
@@ -23,9 +23,8 @@ CHAT_COLUMNS = "cid INTEGER PRIMARY KEY, ctype TEXT, ctitle TEXT, chandle TEXT,
USER_COLUMNS = "ctitle TEXT, full_name TEXT, handle TEXT, tags TEXT, name TEXT, uid INTEGER, cid INTEGER, id INTEGER PRIMARY KEY"
USER_INDEXES = ["uid", "cid"]
-MSG_COLUMNS = "mid INTEGER PRIMARY KEY, mtype TEXT, time TEXT NOT NULL, fullname TEXT, content TEXT, filename TEXT, urls TEXT, reply INTEGER, mime TEXT, user TEXT, uid INTEGER, gid INTEGER, segmented TEXT" # fmt: off
-
-MSG_INDEXES = ["time", "user", "uid"]
+MSG_COLUMNS = "mid INTEGER PRIMARY KEY, mtype TEXT, time TEXT NOT NULL, fullname TEXT, content TEXT, filename TEXT, urls TEXT, reply INTEGER, mime TEXT, user TEXT, handle TEXT, uid INTEGER, gid INTEGER, segmented TEXT" # fmt: off
+MSG_INDEXES = ["time", "user", "uid", "handle"]
async def sync_history_to_turso(client: Client, message: Message) -> None:
@@ -54,6 +53,7 @@ async def sync_history_to_turso(client: Client, message: Message) -> None:
"reply": message.reply_to_message_id,
"mime": info["mime_type"],
"user": info["full_name"].replace(" ", ""),
+ "handle": info["handle"],
"uid": info["uid"],
"gid": info["media_group_id"],
"segmented": " ".join(cutter.cutword(message.content)),
@@ -107,6 +107,7 @@ async def backup_chat_history_to_turso(client: Client, chat_id: str | int, hours
"reply": message.reply_to_message_id,
"mime": info["mime_type"],
"user": info["full_name"].replace(" ", ""),
+ "handle": info["handle"],
"uid": info["uid"],
"gid": info["media_group_id"],
"segmented": " ".join(cutter.cutword(info["text"])),
@@ -215,6 +216,7 @@ async def upload_exported_history_to_turso(client: Client, path: str | Path | No
"reply": info.get("reply_to_message_id"),
"mime": info.get("mime_type", ""),
"user": user.replace(" ", ""),
+ "handle": "", # TODO: parse handle
"uid": uid,
"gid": info.get("media_group_id", 0),
"segmented": " ".join(cutter.cutword(content)),
pyproject.toml
@@ -85,6 +85,8 @@ ignore = [
"ISC001",
"PLR2004",
"S311",
+ "TD",
+ "FIX002",
]
select = ["ALL"]