feat(engagement): templates — the email block family, renderer and seeded set (engagement Phase 5a)
Every subject and body moves out of `mailer.js` into `engagement_templates` rows an operator can edit. A relocation, not a regression: nothing that sends mail today starts depending on an operator authoring something first. - `email.*` block family in its own registry, sharing the page family's envelope walk and validate-then-sanitize order by binding rather than by copy. - A server-side renderer producing both parts of a multipart message; the text part is byte-identical to the literals this commit deletes. - Nine seeded templates, six of them wired now; the seeder's `customized = 0` guard lives in the UPDATE's own WHERE. - `renderByKey` falls back to the shipped seed when a row is missing or unusable, so no failure of the table can stop a password reset. Also fixes `check:hosts` reading the template key `auth.email-verify` as the hostname `auth.email`. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ const assert = require('node:assert/strict')
|
||||
const nodemailer = require('nodemailer')
|
||||
const emailConfig = require('../src/model/emailConfig/emailConfig.model')
|
||||
const settings = require('../src/model/settings/settings.model')
|
||||
const templatesDb = require('../src/model/engagement/engagementTemplates.db')
|
||||
const mailer = require('../src/utils/mailer')
|
||||
const db = require('../src/utils/db')
|
||||
|
||||
@@ -41,6 +42,14 @@ beforeEach(() => {
|
||||
transportCfg = null
|
||||
emailConfig.recordStatus = async () => {}
|
||||
settings.get = async () => 'contact@example.com'
|
||||
// Engagement Phase 5a: every body now comes from `engagement_templates`, so a
|
||||
// send reaches three more model functions than it used to. Stubbed here for the
|
||||
// reason everything else in this file is — the suite must never touch a database
|
||||
// — and `getByKey` answering null exercises the shipped-seed fallback, which is
|
||||
// exactly the state a fresh deployment is in before its first seed runs.
|
||||
settings.getInstanceName = async () => 'UOMysticmoon'
|
||||
settings.getShellBrand = async () => ({ logo: '', favicon: '', theme: null })
|
||||
templatesDb.getByKey = async () => null
|
||||
nodemailer.createTransport = (cfg) => {
|
||||
transportCfg = cfg
|
||||
return { sendMail: async (opts) => { sent = opts; return { messageId: '1' } } }
|
||||
|
||||
Reference in New Issue
Block a user