feat(notify): branded notification mail through an outbox #35

Merged
sharang merged 6 commits from feat/notifications into main 2026-09-23 21:10:07 +00:00
Owner

F3 of the go-live plan, registry side. Stacked on #34 (documents) and #33.

  • Document published → mail to members with IT_ADMIN, OWNER, CXO, FINANCE or LEGAL (the roles that see Documents), linking to PORTAL_URL/<slug>/documents.
  • POST /v1/notifications (new route group notify, meant for pruefwerk-svc-*): {tenant_id, kind: findings.new, idempotency_key, data: {target_name, new_count, critical, high, medium, low, url}} → mail to IT_ADMIN, OWNER, CXO, LEGAL. Inputs are clamped, and the url must be https.
  • Demo tenants and tenants without an organization get nothing. Disabled members and USER never get mail.
  • mail_outbox (migration 0009): one row per recipient, idempotent per key+recipient, rendered at send time. Worker every 20 s with backoff 1 m → 6 h; parked after 12 attempts with the error kept.
  • internal/mail: SMTP with STARTTLS (587) or TLS (465). multipart/alternative text + HTML, UTF-8 quoted-printable, Auto-Submitted. Embedded German (default) and English templates in one BreakPilot layout: table-based, inline CSS, violet button, Impressum and Datenschutz in the footer.
  • Config: SMTP_HOST/PORT/USER/PASSWORD, MAIL_FROM (noreply@breakpilot.com), MAIL_FROM_NAME, PORTAL_URL. Without SMTP_HOST, mail queues unsent.

Not in this PR: per-user opt-out (every mail says why the person receives it) and the recipient's own locale (German for everyone for now).

Tests: both stores. Recipients by role, demo and org-less tenants, idempotent repeats, validation, retry after backoff, template escaping and MIME round-trip.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

F3 of the go-live plan, registry side. **Stacked on #34** (documents) and #33. - **Document published** → mail to members with IT_ADMIN, OWNER, CXO, FINANCE or LEGAL (the roles that see *Documents*), linking to `PORTAL_URL/<slug>/documents`. - **`POST /v1/notifications`** (new route group `notify`, meant for `pruefwerk-svc-*`): `{tenant_id, kind: findings.new, idempotency_key, data: {target_name, new_count, critical, high, medium, low, url}}` → mail to IT_ADMIN, OWNER, CXO, LEGAL. Inputs are clamped, and the url must be https. - Demo tenants and tenants without an organization get nothing. Disabled members and `USER` never get mail. - **`mail_outbox`** (migration 0009): one row per recipient, idempotent per key+recipient, rendered at send time. Worker every 20 s with backoff 1 m → 6 h; parked after 12 attempts with the error kept. - **`internal/mail`**: SMTP with STARTTLS (587) or TLS (465). `multipart/alternative` text + HTML, UTF-8 quoted-printable, `Auto-Submitted`. Embedded **German (default) and English** templates in one BreakPilot layout: table-based, inline CSS, violet button, Impressum and Datenschutz in the footer. - Config: `SMTP_HOST/PORT/USER/PASSWORD`, `MAIL_FROM` (noreply@breakpilot.com), `MAIL_FROM_NAME`, `PORTAL_URL`. Without `SMTP_HOST`, mail queues unsent. Not in this PR: per-user opt-out (every mail says why the person receives it) and the recipient's own locale (German for everyone for now). Tests: both stores. Recipients by role, demo and org-less tenants, idempotent repeats, validation, retry after backoff, template escaping and MIME round-trip. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 3 commits 2026-09-23 17:45:16 +00:00
feat(admin): staff tenant list, detail, trial extension, invite resend
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 22m40s
ci / image (pull_request) Skipped
bab7475a6c
A new route group "admin" (the portal's service client only) serves
the staff admin area: tenant search with 30-day usage and last
activity, one detail call with entitlements, subscriptions, licences,
members and recent audit, trial extension (moves trial entitlements
with it and reopens a trial that expired into read-only), invite
resend, and the audit log across tenants.

Changes made from the admin area are audited under the staff member
the portal names in X-Staff-Subject / X-Staff-Email; the header only
counts from a client that holds the admin group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
feat(documents): tenant documents in object storage
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 23m11s
ci / image (pull_request) Skipped
da6eef6d30
Staff upload a file for a tenant as a draft (streamed to an S3 bucket,
hashed on the way, never buffered whole), publish it, or delete it;
the tenant lists its published documents and gets a five-minute
presigned download link. Uploads, publications and downloads are
audited, a download under the person the portal names.

Migration 0008 adds the documents table; internal/storage wraps
minio-go (Hetzner Object Storage, the bucket is created in its
region when missing). Without DOCUMENTS_S3_* the routes answer 503
and the rest of the registry is unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
feat(notify): branded notification mail through an outbox
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 23m15s
ci / image (pull_request) Skipped
6880f3afc2
Publishing a document now mails the workspace members who may read
documents, and products can POST /v1/notifications (route group
"notify") to report new findings, which reach IT_ADMIN, OWNER, CXO
and LEGAL. Demo tenants and tenants without an organization get
nothing.

Every mail is a mail_outbox row (migration 0009), one per recipient,
idempotent per key, sent by a worker with backoff and parked with its
error after twelve attempts. Messages are rendered when sent from
embedded German and English templates in the BreakPilot layout, as
multipart text + HTML, through the SMTP relay (SMTP_*).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
CODEOWNERS rules requested review from Benjamin_Boenisch 2026-09-23 17:45:16 +00:00
sharang added 2 commits 2026-09-23 20:00:40 +00:00
chore(merge): main into feat/documents after #33
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 23m3s
ci / image (pull_request) Skipped
e99b79f3ff
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
chore(merge): feat/documents into feat/notifications
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 23m21s
ci / image (pull_request) Skipped
5af9526fd3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
sharang added 1 commit 2026-09-23 20:35:51 +00:00
chore: merge main into feat/notifications
ci / shared (pull_request) Successful in 13s
ci / test (pull_request) Successful in 23m20s
ci / image (pull_request) Skipped
609d70972a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB

# Conflicts:
#	cmd/server/main.go
#	internal/config/config.go
#	internal/server/documents.go
#	internal/server/openapi_test.go
#	internal/server/server.go
#	internal/store/memory.go
#	internal/store/store.go
#	internal/store/types.go
#	migrations/migrations_test.go
#	openapi.yaml
sharang merged commit e0bff8c793 into main 2026-09-23 21:10:07 +00:00
Sign in to join this conversation.