fix(tg_inbox): _default_chat_id игнорирует portal:* чаты — портал-канал не Telegram, файлы туда идут push-ом; E2E канала перебивал дефолтный чат → send_document падал 'chat not found'

This commit is contained in:
Simbiot Harness 2026-10-02 00:39:29 +00:00
parent e65d205e0f
commit 3dac41108a

View file

@ -315,8 +315,13 @@ def _default_chat_id():
if not TG_TOKEN:
return None
model = es.run_projections()
# portal:* — это портал-канал (t-261001123121), не Telegram: файлы/тексты
# туда идут через push portal_channel, а не через API Telegram.
# Без фильтра E2E/чат портала «перебивает» личку Alex дефолтным чатом
# → send_message/send_document падают 'chat not found' (найдено 02.10).
inbox = [m for m in (model.get("inbox") or {}).values()
if m.get("chat_id") and not m.get("ignored")]
if m.get("chat_id") and not str(m.get("chat_id")).startswith("portal")
and not m.get("ignored")]
if not inbox:
return None # некому: чат ещё не известен
return sorted(inbox, key=lambda m: m.get("ts") or "")[-1]["chat_id"]