tcef-notifications/.env.example
vjrj d1fc6798dc 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.
2026-07-13 18:49:52 +02:00

65 lines
2.8 KiB
Text

# tcef-notifications — ejemplo de configuración por entorno.
# Copia a .env (o usa config.json). Los SECRETOS salen del repo privado
# tcef-private-config / de shiva — NUNCA se commitean aquí.
# --- Modo y salvaguardas ---
MODE=dry-run # dry-run | shadow | canary | full
KILL_SWITCH=0 # 1 = parada total de envíos
OWNED_CHANNELS= # fcm,email (vacío = no procesa nada)
CANARY_USER_IDS= # userIds separados por coma (modo canary)
CANARY_SUBS_IDS= # subsIds (ObjectId hex) separados por coma
# --- Límites ---
LIMIT_PER_USER_DAY=20 # máx envíos/usuario/24h por canal (0 = sin límite)
LIMIT_MAX_PER_BATCH=2000 # circuit breaker: para y alerta si un ciclo supera esto
# --- Poller ---
POLL_INTERVAL_MS=10000
POLL_BATCH_SIZE=500
# --- Reintentos ---
RETRY_ATTEMPTS=3
RETRY_BACKOFF_MS=5000
# --- Mongo (rsmain, db fuegos) — SECRETO ---
MONGO_URL=mongodb://USER:PASS@simone:27017,rbg:27017,rosaparks:27017/fuegos?replicaSet=rsmain
MONGO_DB=fuegos
# --- Redis ---
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
# REDIS_PASSWORD=
REDIS_DB=0
# --- FCM (HTTP v1) — SECRETO: service account JSON del proyecto org.comunes.fires ---
FCM_SERVICE_ACCOUNT=/opt/tcef-notifications/secrets/firebase-service-account.json
FCM_PROJECT_ID=angular-cosmos-108908
# --- Email — SECRETO: MAIL_URL de los settings de producción de Meteor ---
MAIL_URL=smtps://USER:PASS@smtp.host:465
MAIL_FROM=Todos contra el Fuego <no-reply@comunes.org>
# MAIL_REDIRECT_TO=buzon-de-test@example.com # canary/staging: redirige todo el email aquí
# --- Matcher geoespacial (fase 1b: genera notifications a partir de activefires) ---
MATCHER_MODE=off # off | shadow | full
IRON_PASSWORD= # SECRETO: Meteor.settings.private.ironPassword (para sellar notification.sealed)
MATCHER_AUDIENCE=web,mobile # tipos de suscripción que generan notifs aquí (telegram es fase 1c)
MATCHER_POLL_MS=30000 # cada cuánto sondea activefires (Mongo 3.2, sin change streams)
MATCHER_BATCH=2000 # máx fuegos por ciclo
# --- Telegram (fase 1c: envío de alertas por los bots) ---
# Añade 'telegram' a OWNED_CHANNELS y MATCHER_AUDIENCE para activarlo.
TELEGRAM_TOKEN_ES= # SECRETO: token del bot ES (extraer de flows_cred de node-red)
TELEGRAM_TOKEN_EN= # SECRETO: token del bot EN
TELEGRAM_SERVER= # host para el firelink (por defecto = host de ROOT_URL)
TELEGRAM_GLOBAL_PER_SEC=25 # límite global msg/s por bot (Telegram permite ~30)
TELEGRAM_PER_CHAT_MS=1000 # mínimo ms entre mensajes al mismo chat (~1 msg/s)
# --- Enlaces / mapas ---
ROOT_URL=https://fuegos.comunes.org/
GMAPS_KEY= # Meteor.settings.gmaps.key
FIRE_ICON_URL= # Meteor.settings.private.fireIconUrl
# --- Logs ---
LOG_LEVEL=info
SERVICE_NAME=tcef-notifications