fix(userbot): a deletion that arrives before its message is applied once the message is stored

This commit is contained in:
hh committed 2026-10-19 02:29:19 +00:00
1 parent 516b8e307f
commit f32b772ddc
5 files changed
+56

No files matched your search

@@ -47,6 +47,11 @@ UPDATE messages SET deleted_at = now()
WHERE account_id = $1 AND chat_id = $2 AND message_id = $3 AND date = $4
"""
_MARK_DELETED_LATE = """
UPDATE messages SET deleted_at = now()
WHERE account_id = $1 AND chat_id = $2 AND message_id = $3 AND deleted_at IS NULL
"""
_INSERT_VERSION = """
INSERT INTO message_versions
(account_id, chat_id, message_id, observed_at, edit_date, text, raw)
@@ -310,6 +315,12 @@ async def add_version(pool: asyncpg.Pool, account_id: int, row: MessageRow) -> b
return True
async def mark_deleted_late(
pool: asyncpg.Pool, account_id: int, chat_id: int, message_id: int
) -> None:
await pool.execute(_MARK_DELETED_LATE, account_id, chat_id, message_id)
async def current_media(
pool: asyncpg.Pool, account_id: int, chat_id: int, message_id: int
) -> asyncpg.Record | None: