Repository navigation
[Alertas] Canal email: plantillas, cola de envío y reintentos - #92
Merged
Merged
Conversation
…ut (#81) - _layout.html shared by every email (header, content, footer with the reason and a link to manage the alert); invite and password reset moved onto it, still sent directly because their links carry tokens - alert.html (field table built from the catalog), alert-code-report-analysis.html (service, branch, commit, coloured severities, violated policies) and system-access-changed / system-security-notice for the fixed notices - EventDefinition.mailTemplate, link(context) and mailSummary(payload); subject "[GitOps] <alert>: <summary>"; absolute links from ORIGIN, omitted without it; recipient language or English; stripped from the client catalog - MailQueue: concurrency 3, withRetry 4 attempts 1s/4s/16s with jitter only for network errors and 4xx SMTP replies, definitive failures logged with a recipient hash and no content, drained on sveltekit:shutdown (10 s) - without SMTP: startup warning, debug per skipped event, banner on the alert pages - e2e no longer inherits SMTP settings from a developer's .env - docs: README email section, CLAUDE.md, .env.example, optional mailpit service Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #81 · Parte de #76 · Apilado sobre #91 (#80) → #90 (#79). Cuando se fusionen, la base pasará a
development.Qué incluye
Plantillas (
src/notifications/email/)_layout.htmlyrenderEmail()comunes a todos los emails: cabecera con el producto, contenido y un pie con el motivo ("Recibes este email por la alerta «…» en …") más un enlace para gestionar la alerta.alert.html: plantilla genérica. La tabla de campos se genera desde el catálogo: etiquetas traducidas, enums y booleanos traducidos,referenceresueltas a su nombre y fechas formateadas.alert-code-report-analysis.html(análisis completado y fallido): servicio, herramienta, rama, commit, recuento por severidad con colores, políticas incumplidas y enlace al análisis.system-access-changed.htmlysystem-security-notice.html(API key personal nueva): para las notificaciones de sistema.EventDefinitionadmitemailTemplate,link(context)ymailSummary(payload). El asunto queda[GitOps] {alerta}: {resumen}, p. ej.3 critical, 5 high (9 in total). Estas funciones se quitan del catálogo que llega al cliente.{{ }}(escapados).{{{ }}}solo se usa con HTML generado internamente.ORIGIN. Sin él, el email sale sin enlaces y se avisa al arrancar.Envío
MailQueueen proceso:withRetry: 4 intentos, 1 s → 4 s → 16 s con jitter, solo para errores de red y respuestas SMTP 4xx. Las 5xx (buzón inexistente), los errores de autenticación y los de validación fallan sin reintentar.createLogger('mail'): alerta, evento, hash del destinatario y código de error. No se registra el contenido ni la dirección.sveltekit:shutdown(SIGTERM/SIGINT de adapter-node) se drena la cola durante 10 s como máximo.Configuración y documentación
ORIGINdeclarado ensrc/env.ts.README.mdtiene una sección "Email" con la tabla de variablesNOTIFICATION_SMTP_*yORIGIN..env.exampleyCLAUDE.mdactualizados.docker-compose.ymlincluye un servicio opcionalmailpit(--profile mail) para desarrollo local.A tener en cuenta
.envdel desarrollador, así que podía enviar emails reales a las direcciones@e2e.test. Ahorae2e/global-setup.tslas vacía.docker compose --profile mail up mailpit.Tests
bun run check: 0 errores.bun run test: 604 tests.<script>escapado en el nombre del servicio, en la clave del secreto y en el usuario, enlaces absolutos correctos, sin enlaces cuando no hayORIGIN, tabla desde el catálogo e idioma.bun run test:e2e: 63/63, incluido el banner de email desactivado.🤖 Generated with Claude Code