Skip to main content

Crate cratefield_module_email_signup

Crate cratefield_module_email_signup 

Source
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 — Confirmed, or not on the list.

cratefield-module-email-signup on crates.io cratefield-module-email-signup documentation MIT

§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§

ConfirmMailData
Typed data for email-signup/confirm; templates in ventures deserialize the same shape. The module also puts the resolved theme under theme (see mt::attach_theme).
EmailSignup
Email signup with double opt-in.
WelcomeMailData
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 core Brand, with the deployment’s MAIL_THEME config on top); use themed_templates to compose the venture’s own theme.
themed_templates
The module’s templates in theme, the venture’s own style. The deployment’s MAIL_THEME config still applies on top.