Fase 1c: canal Telegram (telegram-worker) — codigo migrado, inerte

Envio de alertas Telegram desde el servicio (docs/legacy-telegram.md): por alerta,
texto Markdown (content + firelink i18n) + ubicacion, como node-red.

- types: canal 'telegram', notif.type 'telegram', campo telegramNotified
- telegram/message.ts: buildTelegramMessages (firelink es/en/gl + location)
- telegram/client.ts: cliente Bot API (fetch), interpretResponse (429 retry_after,
  403 blocked)
- telegram/rate.ts: throttle por chat (1 msg/s) + computeWaitMs puro
- handlers.processTelegramJob: idempotencia (notification_sends canal telegram),
  modos dry-run/shadow/canary/full, throttle, 429->retry, bloqueo->sub inactiva
- poller/queue/index: canal telegram integrado; worker con rate limiter global
  BullMQ (25/s por bot); cliente por idioma (es/gl->ES, en->EN)
- config: bloque telegram (tokens es/en, server, globalPerSec, perChatMinMs)

85 tests en verde, typecheck y build OK. Sin TELEGRAM_TOKEN_* configurados el
worker no se activa (todo inerte). Falta: extraer tokens de bot de flows_cred +
rollout con el usuario. Los flujos conversacionales de los bots siguen en node-red.
This commit is contained in:
vjrj 2026-07-13 18:49:52 +02:00
parent a1ed206985
commit d1fc6798dc
14 changed files with 479 additions and 14 deletions

View file

@ -74,6 +74,9 @@ sistema) + Redis local. En fase 3 pasa a Docker Compose.
- [x] **1b**: matcher geoespacial (content i18n, geolib, `sealed` vía Iron —
compatible con la web —, dedupe 500 m), ingesta por polling, modos
`shadow`/`full`, comparador de shadow. Tests en verde.
- [x] **1c**: telegram-worker (texto + ubicación, firelink, rate limiting
global 25/s + 1/s por chat, 429/bloqueo, idempotencia). Tests en verde.
**Código migrado; sin tokens configurados → inerte.**
- [ ] **1a full**: envío masivo FCM (~8176 users) — con el usuario, vigilando.
- [ ] **1b**: rollout `shadow` ≥3 días → comparar → cutover node-red → `full`.
- [ ] **1c**: envío Telegram.
- [ ] **1c**: extraer tokens de bot → rollout `shadow`/canary → cutover node-red.