Files
beavergram/backend/src/userbot/modules/read_receipts/repository.py
T

37 lines
837 B
Python

from datetime import datetime
import asyncpg
_INSERT = """
INSERT INTO read_receipts
(account_id, chat_id, message_id, ts, reader_id, kind, raw)
VALUES ($1, $2, $3, $4, $5, $6, $7::jsonb)
ON CONFLICT (account_id, chat_id, message_id, ts) DO NOTHING
"""
async def insert_read( # noqa: PLR0913
pool: asyncpg.Pool,
account_id: int,
chat_id: int,
reader_id: int,
ts: datetime,
max_id: int,
raw: str,
) -> None:
await pool.execute(_INSERT, account_id, chat_id, max_id, ts, reader_id, "read", raw)
async def insert_listened( # noqa: PLR0913
pool: asyncpg.Pool,
account_id: int,
chat_id: int,
reader_id: int,
ts: datetime,
message_id: int,
raw: str,
) -> None:
await pool.execute(
_INSERT, account_id, chat_id, message_id, ts, reader_id, "listened", raw
)