The free trial follows the contract states of the epic: the customer's
binding offer (§ 2 Abs. 1 Testbedingungen) → receipt with confirmation link
(§ 312i Abs. 1 Nr. 3 BGB) → Breakpilot accepts by activating once the
address is confirmed: contract concluded, 14 calendar days start.
- Trial terms v1.0 ("Bedingungen für den kostenlosen Breakpilot-Testzugang",
Stand 1. Oktober 2026) as committed Markdown, HTML and PDF, embedded, with
pinned SHA-256; public at /v1/legal/trial-terms[/1.0.{pdf,html,md}], the
same bytes before the offer, in the activation mail and in the tenant's
Vertragsunterlagen.
- Migration 0011 trial_offers: the offer snapshot (company, address, person,
e-mail, terms id/version/sha256, 246c notice version, flow version,
language, offered_at) is immutable (trigger); only the state moves.
No IP address or browser fingerprint.
- POST /v1/trial-offers: validation, version check against what the portal
showed (409 version_mismatch), 409 email_taken, 429 within 10 minutes;
receipt mail with a single-use 72-hour link (only its hash is stored).
- POST /v1/trial-offers/verify: activated / already_activated / 410 expired
/ 404 invalid. Activation creates the tenant (slug from the company name),
the Keycloak account with the address already verified (only
UPDATE_PASSWORD), trial_ends_at = contract time + 14 calendar days in
Berlin time, the audit chain (offer_submitted, email_verified,
contract_accepted, activated) and the activation mail with the PDF.
- POST /v1/trial-offers/{id}/resend; GET /v1/tenants/{id}/contracts (trial,
AVV, TOMs, SaaS; trial null for tenants without an offer) and the exact
accepted PDF; trial.extension_granted event from the admin extension.
- mail: attachments (multipart/mixed); German-only registry mails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
79 lines
2.1 KiB
Go
79 lines
2.1 KiB
Go
package mail
|
|
|
|
import (
|
|
"bytes"
|
|
"embed"
|
|
"fmt"
|
|
htmltpl "html/template"
|
|
"strings"
|
|
texttpl "text/template"
|
|
)
|
|
|
|
//go:embed templates/*
|
|
var templates embed.FS
|
|
|
|
// Kinds the registry can send.
|
|
const (
|
|
KindDocumentPublished = "document.published"
|
|
KindFindingsNew = "findings.new"
|
|
)
|
|
|
|
// Kinds lists every kind products may request (POST /v1/notifications).
|
|
var Kinds = map[string]bool{KindDocumentPublished: true, KindFindingsNew: true}
|
|
|
|
// Registry-only kinds (portal#64): German only, sent directly, never queued
|
|
// by a product.
|
|
const (
|
|
KindTrialReceived = "trial.received"
|
|
KindTrialActivated = "trial.activated"
|
|
)
|
|
|
|
var internalKinds = map[string]bool{KindTrialReceived: true, KindTrialActivated: true}
|
|
|
|
// View is what a template sees.
|
|
type View struct {
|
|
Lang string
|
|
Tenant string
|
|
URL string
|
|
Subject string
|
|
D map[string]any
|
|
}
|
|
|
|
// Render builds the subject, text and HTML body of kind in locale ("de"
|
|
// unless "en"). HTML values are escaped by html/template; the text body and
|
|
// subject are plain.
|
|
func Render(kind, locale string, v View) (Message, error) {
|
|
if !Kinds[kind] && !internalKinds[kind] {
|
|
return Message{}, fmt.Errorf("mail: unknown kind %q", kind)
|
|
}
|
|
if locale != "en" || internalKinds[kind] {
|
|
locale = "de"
|
|
}
|
|
v.Lang = locale
|
|
if v.D == nil {
|
|
v.D = map[string]any{}
|
|
}
|
|
file := "templates/" + locale + "_" + kind + ".tmpl"
|
|
tt, err := texttpl.ParseFS(templates, "templates/signature.tmpl", file)
|
|
if err != nil {
|
|
return Message{}, err
|
|
}
|
|
var subj, text bytes.Buffer
|
|
if err := tt.ExecuteTemplate(&subj, "subject", v); err != nil {
|
|
return Message{}, err
|
|
}
|
|
if err := tt.ExecuteTemplate(&text, "text", v); err != nil {
|
|
return Message{}, err
|
|
}
|
|
v.Subject = strings.Join(strings.Fields(subj.String()), " ")
|
|
ht, err := htmltpl.ParseFS(templates, "templates/layout.html", "templates/signature.tmpl", file)
|
|
if err != nil {
|
|
return Message{}, err
|
|
}
|
|
var html bytes.Buffer
|
|
if err := ht.ExecuteTemplate(&html, "layout", v); err != nil {
|
|
return Message{}, err
|
|
}
|
|
return Message{Subject: v.Subject, Text: strings.TrimSpace(text.String()) + "\n", HTML: html.String()}, nil
|
|
}
|