Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
invite_email
What it is
Belongs to notifications: domain models and Askama templates for invitation emails — referral-to-Macro invites, team invites, channel invites, call invites, and the colleague-joined email.
Start here
src/lib.rs:InviteToMacro,ReferralCode, and the other top-level notification metadata types — each derivesTemplateagainst a file intemplates/.src/call_invite.rs,src/colleague_joined.rs: the remaining notification metadata types, one file each.templates/*.html: the actual email markup (Askama/Jinja2-compatible syntax). An email that needs an unsubscribe link putsnotification::domain::models::signing::unsubscribe_placeholder(TYPE_NAME)in thehref; the notification service signs it per recipient at send time, and the type must be in the service's blockable list.preview_invite.py: renderstemplates/invite.htmlwith dummy data via Jinja2 and opens it in a browser — use this to check template changes without sending an email (pip3 install jinja2if needed).
Scope
- Owns: invite/referral/colleague-joined email notification metadata and templates.
- Not here: sending/queuing the notification →
crates/notification; who triggers an invite →crates/call,crates/referral,model_notifications.
Boundaries
- Depends on:
notification(forNotification,NotificationExtEmailtypes),macro_env,macro_user_id,model-entity. - Used by:
model_notifications,call,referral.
Recipes
DM message emails include a stable message ID in the rate-limit key, so retries are suppressed without dropping subsequent messages. Ordinary channel invitations retain their sender/channel limit.
Add a new invite email: new metadata type in
src/<name>.rsderivingTemplate→templates/<name>.html→pub useit fromsrc/lib.rs.Change an email's markup:
templates/<name>.html→ preview withpreview_invite.py(edit its dummy data / template path first) → verify against the type's fields insrc/lib.rs.
Checks
cargo test -p invite_email.
Gotchas
- The team invite email promises what joining gives (
InviteePlan). The sender,teams'invite_users_to_team, derives it the wayjoin_teamgrants entitlements: Pro only from an enterprise team or one with a subscription. Never let the copy promise more than the join grants. - The team invite email is sent on the inviter's behalf:
format_emailsetsfrom_name(their name),reply_to(their address) and a plain-texttextpart that mirrors the HTML copy.inviter_nameis untrusted and optional, so the subject, body and text fall back to the inviter's address;from_namestays unset without a name, since an address as a display name looks like spoofing to mail filters.teamslooks the name up when it sends the invite. InviteToTeamMetadata.remindermarks the reminder emailsteamssends for unanswered invites; it only prefixes the subject with "Reminder:". A reminder shares the invite's rate-limit bucket (one email per invite per hour), so reminders must stay more than an hour apart. Manual resends wait out the same window:teamsreads it fromInviteToTeamMetadata::rate_limit_config()(invite_resend_interval), and the web app's Resend mirrors it inteamInviteResend.ts.- Metadata is queued and stored as JSON, and the notification service
publishes it in its OpenAPI spec. A new field needs
#[serde(default)]so payloads queued before a deploy still deserialize, and a regenerated web client (bun run gen-api notification-serviceinapps/web).
Related
- Docs:
packages/email-renderer/README.md(if rendering in the standalone renderer rather than the email template pipeline here)