feat: log presence, read receipts, group leaves, links, profiles, stories

This commit is contained in:
hh committed 2026-05-29 22:13:59 +02:00
1 parent bfd16ab02c
commit bcb94b6474
31 files changed
+1298 -19

No files matched your search

@@ -0,0 +1,68 @@
from datetime import datetime
import asyncpg
_INSERT_CHAT_HISTORY = """
INSERT INTO chat_history
(account_id, chat_id, message_id, event, title, photo_unique_id, actor_id,
ts, raw)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9::jsonb)
ON CONFLICT (account_id, chat_id, message_id) DO NOTHING
"""
_INSERT_MEMBERSHIP = """
INSERT INTO memberships
(account_id, chat_id, message_id, user_id, event, actor_id, ts, raw)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8::jsonb)
ON CONFLICT (account_id, chat_id, message_id, user_id) DO NOTHING
"""
async def insert_chat_history( # noqa: PLR0913
pool: asyncpg.Pool,
account_id: int,
chat_id: int,
message_id: int,
event: str,
title: str | None,
photo_unique_id: str | None,
actor_id: int | None,
ts: datetime,
raw: str,
) -> None:
await pool.execute(
_INSERT_CHAT_HISTORY,
account_id,
chat_id,
message_id,
event,
title,
photo_unique_id,
actor_id,
ts,
raw,
)
async def insert_membership( # noqa: PLR0913
pool: asyncpg.Pool,
account_id: int,
chat_id: int,
message_id: int,
user_id: int,
event: str,
actor_id: int | None,
ts: datetime,
raw: str,
) -> None:
await pool.execute(
_INSERT_MEMBERSHIP,
account_id,
chat_id,
message_id,
user_id,
event,
actor_id,
ts,
raw,
)