Expand description
cratefield-module-email-signup: collect an address, double opt-in via
a signed link, one-click unsubscribe, admin CSV export and hard delete
(issue #10, architecture section 6).
use cratefield_module_email_signup::EmailSignup;
let module = EmailSignup::new()
.double_opt_in(true)
.confirm_ttl_days(7)
.retention_days_pending(30);No enumeration (section 11): POST /v1/email-signup answers the
same 202 {"ok":true} bytes for new, pending, confirmed and
unsubscribed addresses, and at most one confirmation mail is sent per
address per hour. Tokens are HMAC-signed (ADR 0006): confirm links
expire after confirm_ttl_days, unsubscribe links never do.
Register default_templates with Harness::builder().templates(..)
so ventures can override them; the module also falls back to built-in
rendering when the registry has no entry.
§cratefield-module-email-signup
Email signup for a Cratefield venture: POST /v1/email-signup collects
an address, double opt-in via a signed confirmation link, one-click
unsubscribe, admin CSV export and hard delete.
use cratefield_module_email_signup::EmailSignup;
let module = EmailSignup::new()
.double_opt_in(true)
.confirm_ttl_days(7)
.retention_days_pending(30);Composable with cratefield-module-waitlist:
use cratefield_module_email_signup::EmailSignup;
let module = EmailSignup::new().subscribe_on_waitlist_confirm(true);adds confirmed waitlist addresses to the signup list through the
waitlist.confirmed event — no crate dependency between the modules.
Register the mail templates in the venture’s src/lib.rs, in the
venture’s own style: they render through cratefield-mail-templates
(ADR 0030) with the MailTheme you give them. default_templates() renders
in a theme built from the venture’s core Brand and its MAIL_THEME config
instead; either way, venture overrides registered later win.
use cratefield_core::Harness;
use cratefield_mail_templates::{MailTheme, Palette};
use cratefield_module_email_signup::themed_templates;
let theme = MailTheme::new("Acme", "https://acme.test")
.logo("https://acme.test/assets/email/logo-64.png", "Acme")
.light(Palette::neutral_light().button("#0E1526"));
let builder = Harness::builder().templates(themed_templates(&theme));See docs/ARCHITECTURE.md section 6 (Email signup) and section 11
(no enumeration, tokens, admin auth, retention).
MIT. Built in the open for Cratefield, a Factory Zero venture.
Structs§
- Confirm
Mail Data - Typed data for
email-signup/confirm; templates in ventures deserialize the same shape. The module also puts the resolved theme undertheme(seemt::attach_theme). - Email
Signup - Email signup with double opt-in.
- Welcome
Mail Data - Typed data for
email-signup/welcome.
Functions§
- default_
templates - The module’s default templates, for
Harness::builder().templates(..). Ventures register them first and their overrides second. They render in the theme the module resolves for each mail (the venture’s coreBrand, with the deployment’sMAIL_THEMEconfig on top); usethemed_templatesto compose the venture’s own theme. - themed_
templates - The module’s templates in
theme, the venture’s own style. The deployment’sMAIL_THEMEconfig still applies on top.