fix(backend): watch times stay in utc for naive telegram dates, webhook outbox survives a database hiccup at start

This commit is contained in:
hh committed 2026-10-19 02:57:27 +00:00
1 parent 2c56934133
commit 97ccfbbffd
3 files changed
+14 -5

No files matched your search

+4 -1
View File
@@ -155,11 +155,14 @@ class Outbox:
self._wake.set()
async def run(self, pool: asyncpg.Pool) -> None:
await webhooks_read.release_stuck(pool)
released = False
async with new_client() as client:
while True:
self._wake.clear()
try:
if not released:
await webhooks_read.release_stuck(pool)
released = True
await self._drain(pool, client)
delay = await self._delay(pool)
except Exception:
+2 -2
View File
@@ -1,6 +1,6 @@
from __future__ import annotations
from datetime import datetime, timedelta
from datetime import UTC, datetime, timedelta
from typing import TYPE_CHECKING, Any
from userbot.modules.watches import repository
@@ -159,7 +159,7 @@ class WatchCache:
if not watch_ids:
return
if status != "online":
self._last_seen[peer_id] = last_online or at
self._last_seen[peer_id] = (last_online or at).astimezone(UTC)
return
await self._guard(self._on_online(peer_id, at, watch_ids))
+8 -2
View File
@@ -1,9 +1,15 @@
from datetime import UTC, datetime
from pyrogram.types import Message
from userbot.modules.capture.message import sender_id
from userbot.modules.watches.evaluator import Seen
def utc(moment: datetime | None) -> datetime | None:
return moment.astimezone(UTC) if moment else None
def seen_message(chat_id: int, message: Message) -> Seen:
return Seen(
chat_id=chat_id,
@@ -11,6 +17,6 @@ def seen_message(chat_id: int, message: Message) -> Seen:
sender_id=sender_id(message),
text=message.text or message.caption,
outgoing=bool(message.outgoing),
date=message.date,
edit_date=message.edit_date,
date=utc(message.date),
edit_date=utc(message.edit_date),
)