domma-cms 1.76.0 → 1.78.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/admin/js/lib/shortcode-registry.js +1 -1
- package/admin/js/lib/site-settings-arrange.js +3 -3
- package/admin/js/templates/docs/usage-shortcodes-content.html +3 -2
- package/admin/js/templates/settings.html +26 -0
- package/admin/js/views/settings.js +3 -3
- package/docs/DommaFeatures.md +2 -2
- package/docs/markdown-shortcodes.md +18 -3
- package/docs/screenshots/email-branding-gallery.png +0 -0
- package/docs/screenshots/email-branding-waypoint.png +0 -0
- package/package.json +1 -1
- package/plugins/_lib/admin/mail/body-menu.js +1 -1
- package/plugins/_lib/admin/mail/cms-host.js +1 -1
- package/plugins/_lib/admin/mail/compose-window.js +1 -1
- package/plugins/_lib/admin/mail/contacts.js +1 -1
- package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
- package/plugins/_lib/admin/mail/drag-drop.js +1 -1
- package/plugins/_lib/admin/mail/folder-tree.js +1 -1
- package/plugins/_lib/admin/mail/font-controls.js +1 -1
- package/plugins/_lib/admin/mail/fonts.js +1 -1
- package/plugins/_lib/admin/mail/host-context.js +1 -1
- package/plugins/_lib/admin/mail/identity.js +1 -1
- package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
- package/plugins/_lib/admin/mail/keyboard.js +1 -1
- package/plugins/_lib/admin/mail/mail.html +1 -1
- package/plugins/_lib/admin/mail/message-actions.js +1 -1
- package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
- package/plugins/_lib/admin/mail/panes.js +1 -1
- package/plugins/_lib/admin/mail/reader-kit.js +1 -1
- package/plugins/_lib/admin/mail/reader-runtime.js +1 -1
- package/plugins/_lib/admin/mail/reader-view.js +1 -1
- package/plugins/_lib/admin/mail/resizable.js +1 -1
- package/plugins/_lib/admin/mail/restore-spam.js +1 -1
- package/plugins/_lib/admin/mail/rules.js +1 -1
- package/plugins/_lib/admin/mail/scheduling.js +1 -1
- package/plugins/_lib/admin/mail/section-kit.js +1 -1
- package/plugins/_lib/admin/mail/security-note.js +1 -1
- package/plugins/_lib/admin/mail/settings-section.js +1 -1
- package/plugins/_lib/admin/mail/templates.js +1 -1
- package/plugins/_lib/admin/mail/threads.js +1 -1
- package/plugins/_lib/admin/mail/vacation.js +1 -1
- package/plugins/_lib/admin/mail/when-closed.js +1 -1
- package/plugins/_lib/admin/ui/dates.js +1 -1
- package/plugins/_lib/admin/ui/resizable.js +1 -1
- package/plugins/_lib/admin/ui/rich-field.js +1 -1
- package/plugins/_lib/domma-mail.lock.json +83 -83
- package/plugins/_lib/mail/accountFileStore.js +1 -1
- package/plugins/_lib/mail/accountRepository.js +1 -1
- package/plugins/_lib/mail/accountRoutes.js +1 -1
- package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
- package/plugins/_lib/mail/bodyTokens.js +1 -1
- package/plugins/_lib/mail/compose.js +1 -1
- package/plugins/_lib/mail/defaults.js +1 -1
- package/plugins/_lib/mail/envelope.js +1 -1
- package/plugins/_lib/mail/folderActions.js +1 -1
- package/plugins/_lib/mail/folderRuntime.js +1 -1
- package/plugins/_lib/mail/folders.js +1 -1
- package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
- package/plugins/_lib/mail/mbox.js +1 -1
- package/plugins/_lib/mail/message-action.js +1 -1
- package/plugins/_lib/mail/messageSecurity.js +1 -1
- package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
- package/plugins/_lib/mail/networkAddresses.js +1 -1
- package/plugins/_lib/mail/networkPolicy.js +1 -1
- package/plugins/_lib/mail/oauthAccounts.js +1 -1
- package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
- package/plugins/_lib/mail/oauthRuntime.js +1 -1
- package/plugins/_lib/mail/pollSchedule.js +1 -1
- package/plugins/_lib/mail/poller.js +1 -1
- package/plugins/_lib/mail/pollerRuntime.js +1 -1
- package/plugins/_lib/mail/priority.js +1 -1
- package/plugins/_lib/mail/publicMailbox.js +1 -1
- package/plugins/_lib/mail/readRuntime.js +1 -1
- package/plugins/_lib/mail/render.js +1 -1
- package/plugins/_lib/mail/ruleRunner.js +1 -1
- package/plugins/_lib/mail/schedulerRuntime.js +1 -1
- package/plugins/_lib/mail/secretProvider.js +1 -1
- package/plugins/_lib/mail/secretbox.js +1 -1
- package/plugins/_lib/mail/senderAuth.js +1 -1
- package/plugins/_lib/mail/sieve.js +1 -1
- package/plugins/_lib/mail/smtpService.js +1 -1
- package/plugins/_lib/mail/snoozeRuntime.js +1 -1
- package/plugins/_lib/mail/store.js +1 -1
- package/plugins/_lib/mail/subscriptions.js +1 -1
- package/plugins/_lib/mail/syncPlan.js +1 -1
- package/plugins/_lib/mail/syncRuntime.js +1 -1
- package/plugins/_lib/mail/syncSelection.js +1 -1
- package/plugins/_lib/mail/unreadBadge.js +1 -1
- package/plugins/_lib/mail/unsubscribe.js +1 -1
- package/plugins/_lib/mail/vacationRunner.js +14 -2
- package/plugins/_lib/mail/vacationRuntime.js +23 -5
- package/plugins/_lib/mail/write.js +1 -1
- package/plugins/_lib/outreach/sending.js +3 -1
- package/plugins/_lib/public/rich-text.mjs +1 -1
- package/plugins/_lib/rich-text.js +1 -1
- package/plugins/docs/CHANGELOG.md +5 -0
- package/plugins/docs/plugin.js +2 -2
- package/plugins/free-tier.lock.json +7 -7
- package/plugins/shopping-cart/CHANGELOG.md +5 -0
- package/plugins/shopping-cart/lib/accounts.js +1 -1
- package/plugins/support/CHANGELOG.md +5 -0
- package/plugins/support/lib/mail.js +2 -2
- package/server/routes/api/settings.js +45 -8
- package/server/services/actions.js +2 -1
- package/server/services/callInvites.js +1 -1
- package/server/services/content.js +5 -0
- package/server/services/email.js +10 -4
- package/server/services/emailBrand.js +126 -0
- package/server/services/emailExamples.js +37 -0
- package/server/services/geocode.js +158 -0
- package/server/services/instantCalls.js +1 -1
- package/server/services/mapPins.js +45 -11
- package/server/services/markdown.js +13 -4
- package/server/services/passwordReset.js +4 -4
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Shared, opt-in presentation for automated site emails. No SMTP or runtime writes. */
|
|
2
|
+
const esc = value => String(value ?? '').replace(/[&<>"']/g, c => ({'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[c]));
|
|
3
|
+
const clean = (value, max = 300) => typeof value === 'string' ? value.replace(/[\u0000-\u001f\u007f]/g, ' ').trim().slice(0, max) : '';
|
|
4
|
+
const hex = value => /^#[\da-f]{6}$/i.test(value || '');
|
|
5
|
+
|
|
6
|
+
export const EMAIL_FAMILIES = {
|
|
7
|
+
account: 'Your account', waypoint: 'Waypoint', booking: 'Bookings', calendar: 'Calendar',
|
|
8
|
+
shop: 'Your order', invoice: 'Invoices and quotes', support: 'Support', docs: 'Documents', signing: 'Document signing',
|
|
9
|
+
forms: 'Form submission', automation: 'Site notification', report: 'Your report', security: 'Account security',
|
|
10
|
+
campaign: 'News and updates', survey: 'Your invitation', onboard: 'Getting started', ecard: 'A card for you',
|
|
11
|
+
prize: 'Your reward', recovery: 'Account recovery', jobs: 'Job board', wiki: 'Wiki updates', test: 'Email preview',
|
|
12
|
+
gift: 'A gift for you', offer: 'An offer for you', licence: 'Your licence'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** Site identity, with explicit email overrides. Never use the admin identity on customer mail. */
|
|
16
|
+
export function emailBrand(site = {}) {
|
|
17
|
+
const override = site.emailBrand || {};
|
|
18
|
+
const base = emailUrl(site.baseUrl) || emailUrl(site.url);
|
|
19
|
+
const colour = /^#[\da-f]{3}$/i.test(override.accent || '') ? '#' + override.accent.slice(1).split('').map(c => c + c).join('') : override.accent;
|
|
20
|
+
const accent = hex(colour) ? colour : '#2563eb';
|
|
21
|
+
const support = clean(override.supportEmail || site.contactEmail);
|
|
22
|
+
return {
|
|
23
|
+
name: clean(override.name || site.brand?.text || site.title || site.smtp?.fromName || 'Our team', 120),
|
|
24
|
+
logo: /\.svg(?:[?#]|$)/i.test(override.logo || site.brand?.logo || site.logo || '') ? '' : emailUrl(override.logo || site.brand?.logo || site.logo, base),
|
|
25
|
+
accent, ink: accentInk(accent), link: accentInk(accent) === '#000000' ? '#0f172a' : accent, base,
|
|
26
|
+
supportEmail: /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(support) ? support : '',
|
|
27
|
+
footer: clean(override.footer, 600)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function accentInk(accent) {
|
|
32
|
+
const rgb = accent.slice(1).match(/../g).map(x => parseInt(x, 16) / 255).map(x => x <= .04045 ? x / 12.92 : ((x + .055) / 1.055) ** 2.4);
|
|
33
|
+
const luminance = .2126 * rgb[0] + .7152 * rgb[1] + .0722 * rgb[2];
|
|
34
|
+
return (luminance + .05) / .05 > 1.05 / (luminance + .05) ? '#000000' : '#ffffff';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Structured content is escaped here; html fragments are trusted template output only. */
|
|
38
|
+
export function emailBlocks(blocks = [], brand = emailBrand()) {
|
|
39
|
+
const pieces = blocks.map(block => {
|
|
40
|
+
if (block.type === 'details') {
|
|
41
|
+
const rows = (block.rows || []).filter(([, value]) => value !== '' && value != null);
|
|
42
|
+
return {html: `${block.title ? `<p style="margin:20px 0 8px;"><strong>${esc(block.title)}</strong></p>` : ''}<table role="presentation" class="dm-email-panel" bgcolor="#f8fafc" width="100%" cellpadding="0" cellspacing="0" style="background:#f8fafc;margin:20px 0;border:1px solid #e2e8f0;border-radius:8px;">${rows.map(([label, value]) => `<tr><td style="padding:10px 14px;vertical-align:top;color:#64748b;border-bottom:1px solid #e2e8f0;width:35%;">${esc(label)}</td><td style="padding:10px 14px;vertical-align:top;border-bottom:1px solid #e2e8f0;font-weight:600;">${esc(value).replace(/\n/g, '<br>')}</td></tr>`).join('')}</table>`, text: (block.title ? `${block.title}:\n` : '') + rows.map(([label, value]) => `${label}: ${String(value).replace(/\n/g, '\n ')}`).join('\n')};
|
|
43
|
+
}
|
|
44
|
+
if (block.type === 'link') {
|
|
45
|
+
const href = emailUrl(block.url, brand.base);
|
|
46
|
+
return href ? {html: `<p style="font-size:12px;margin:18px 0;"><a href="${esc(href)}" class="dm-email-link" style="color:${brand.link};">${esc(block.label)}</a></p>`, text: `${block.label}: ${href}`} : {html: '', text: ''};
|
|
47
|
+
}
|
|
48
|
+
if (block.type === 'action') {
|
|
49
|
+
const href = emailUrl(block.url, brand.base);
|
|
50
|
+
return href ? {html: `<table role="presentation" cellpadding="0" cellspacing="0" style="margin:26px 0;"><tr><td bgcolor="${brand.accent}" style="border-radius:6px;background:${brand.accent};"><a href="${esc(href)}" style="display:inline-block;padding:14px 24px;font-weight:700;color:${brand.ink};text-decoration:none;">${esc(block.label || 'Open')}</a></td></tr></table><p style="font-size:12px;color:#64748b;word-break:break-all;">Or open this link:<br><a href="${esc(href)}" class="dm-email-link" style="color:${brand.link};">${esc(href)}</a></p>`, text: `${block.label || 'Open'}: ${href}`} : {html: '', text: ''};
|
|
51
|
+
}
|
|
52
|
+
if (block.type === 'quote') return {html: `<blockquote class="dm-email-panel" style="margin:20px 0;padding:16px 20px;border-left:4px solid ${brand.accent};background:#f8fafc;">${esc(block.text).replace(/\n/g, '<br>')}</blockquote>`, text: block.text || ''};
|
|
53
|
+
if (block.type === 'items') return {html: `<ul style="padding-left:20px;">${(block.items || []).map(item => `<li style="margin:12px 0;">${esc(item)}</li>`).join('')}</ul>`, text: (block.items || []).map(item => `- ${item}`).join('\n')};
|
|
54
|
+
if (block.type === 'status') return {html: `<p style="margin:16px 0;padding:12px 16px;border:1px solid #cbd5e1;border-radius:6px;font-weight:700;">${esc(block.text)}</p>`, text: block.text || ''};
|
|
55
|
+
return {html: `<p style="margin:0 0 18px;">${esc(block.text).replace(/\n/g, '<br>')}</p>`, text: block.text || ''};
|
|
56
|
+
});
|
|
57
|
+
return {html: pieces.map(p => p.html).join('\n'), text: pieces.map(p => p.text).filter(Boolean).join('\n\n')};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Adapt existing trusted templates without nesting full HTML documents or losing attachment metadata. */
|
|
61
|
+
function fragment(html, brand, preserveLayout) {
|
|
62
|
+
let output = String(html || '');
|
|
63
|
+
const styles = preserveLayout ? (output.match(/<head\b[^>]*>([\s\S]*?)<\/head\s*>/i)?.[1].match(/<style\b[^>]*>[\s\S]*?<\/style\s*>/gi) || []).join('') : '';
|
|
64
|
+
output = output.replace(/<head\b[^>]*>[\s\S]*?<\/head\s*>/gi, '');
|
|
65
|
+
output = output.replace(/<!doctype[^>]*>|<\/?(?:html|body)\b[^>]*>/gi, '');
|
|
66
|
+
if (!preserveLayout) {
|
|
67
|
+
output = output.replace(/<style\b[^>]*>[\s\S]*?<\/style\s*>/gi, '');
|
|
68
|
+
output = output.replace(/style="([^"]*)"/gi, (all, style) => {
|
|
69
|
+
if (!/background(?:-color)?:\s*#(?:2563eb|5b8cff|1f5bb8)\b/i.test(style)) return all;
|
|
70
|
+
const next = style.replace(/background(?:-color)?:[^;]+;?/gi, '').replace(/(?:^|;)\s*color:[^;]+;?/gi, ';');
|
|
71
|
+
return `style="${next};background-color:${brand.accent};color:${brand.ink};"`;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return styles + output;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Explicit opt-in: SMTP stays a transport, and manually composed mail is never decorated. */
|
|
78
|
+
export function brandEmail(message, {site = {}, family = 'automation', title, preview, blocks, preserveLayout = false} = {}) {
|
|
79
|
+
if (String(message.html || '').includes('data-domma-email="1"')) return {...message};
|
|
80
|
+
const brand = emailBrand(site);
|
|
81
|
+
const heading = clean(title || message.subject || 'A message for you', 240);
|
|
82
|
+
const label = EMAIL_FAMILIES[family] || EMAIL_FAMILIES.automation;
|
|
83
|
+
const content = blocks ? emailBlocks(blocks, brand) : message.html ? {html: fragment(message.html, brand, preserveLayout), text: message.text || ''} : emailBlocks([{text: message.text || ''}], brand);
|
|
84
|
+
if (family === 'account' && !preserveLayout) content.html = content.html.replace(/<h2\b[^>]*>[\s\S]*?<\/h2>/i, '');
|
|
85
|
+
const preheader = clean(preview || content.text || heading, 180);
|
|
86
|
+
const contact = brand.supportEmail ? `<a href="mailto:${esc(brand.supportEmail)}" style="color:#64748b;">${esc(brand.supportEmail)}</a>` : '';
|
|
87
|
+
const website = brand.base ? `<a href="${esc(brand.base)}" style="color:#64748b;">Visit ${esc(brand.name)}</a>` : '';
|
|
88
|
+
const logo = brand.logo ? `<img src="${esc(brand.logo)}" alt="${esc(brand.name)}" width="160" style="display:block;max-width:160px;max-height:64px;width:auto;height:auto;border:0;margin-bottom:14px;">` : '';
|
|
89
|
+
const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light dark"><title>${esc(heading)}</title><style>@media(max-width:600px){.dm-email-pad{padding:24px 20px!important}.dm-email-shell{border-radius:0!important}}@media(prefers-color-scheme:dark){.dm-email-page{background:#111827!important}.dm-email-shell,.dm-email-content{background:#1f2937!important;color:#f1f5f9!important}.dm-email-title,.dm-email-brand div{color:#fff!important}.dm-email-panel{background:#334155!important;color:#f1f5f9!important}.dm-email-panel td{color:inherit!important}.dm-email-preserve{background:#fff!important;color:#334155!important}.dm-email-preserve .dm-email-title{color:#0f172a!important}.dm-email-link{color:#93c5fd!important}.dm-email-footer a{color:#cbd5e1!important}.dm-email-footer{background:#172033!important;color:#cbd5e1!important}}</style></head>
|
|
90
|
+
<body class="dm-email-page" style="margin:0;padding:0;background:#edf1f6;"><div style="display:none;max-height:0;overflow:hidden;mso-hide:all;">${esc(preheader)}</div>
|
|
91
|
+
<table data-domma-email="1" role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" class="dm-email-page" style="background:#edf1f6;font:15px/1.65 Arial,Helvetica,sans-serif;color:#334155;"><tr><td align="center" style="padding:36px 12px;">
|
|
92
|
+
<table role="presentation" width="600" cellpadding="0" cellspacing="0" border="0" class="dm-email-shell" style="width:100%;max-width:600px;background:#fff;border:1px solid #dce3ed;border-radius:12px;overflow:hidden;">
|
|
93
|
+
<tr><td bgcolor="${brand.accent}" style="height:6px;font-size:0;line-height:6px;background:${brand.accent};"> </td></tr>
|
|
94
|
+
<tr><td class="dm-email-pad dm-email-brand" style="padding:28px 36px 20px;">${logo}<div style="font-size:18px;font-weight:700;color:#0f172a;">${esc(brand.name)}</div><div style="margin-top:4px;font-size:11px;font-weight:700;letter-spacing:1.4px;text-transform:uppercase;color:#64748b;">${esc(label)}</div></td></tr>
|
|
95
|
+
<tr><td class="dm-email-pad dm-email-content${blocks ? '' : ' dm-email-preserve'}" style="padding:8px 36px 32px;background:#fff;color:#334155;"><h1 class="dm-email-title" style="font:700 26px/1.25 Arial,Helvetica,sans-serif;color:#0f172a;margin:0 0 24px;">${esc(heading)}</h1><!--dm-email-body-->${content.html}<!--/dm-email-body--></td></tr>
|
|
96
|
+
<tr><td class="dm-email-pad dm-email-footer" style="padding:22px 36px;background:#f8fafc;border-top:1px solid #e2e8f0;font:12px/1.6 Arial,Helvetica,sans-serif;color:#64748b;"><strong>${esc(brand.name)}</strong>${brand.footer ? `<p style="margin:8px 0;">${esc(brand.footer)}</p>` : ''}<p style="margin:8px 0 0;">${[website, contact].filter(Boolean).join(' · ')}</p></td></tr>
|
|
97
|
+
</table></td></tr></table></body></html>`;
|
|
98
|
+
const text = [brand.name, label, heading, content.text, brand.footer, brand.base, brand.supportEmail].filter(Boolean).join('\n\n');
|
|
99
|
+
return {...message, html, text};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Store only email presentation fields. Blank overrides inherit the site's public identity. */
|
|
103
|
+
export function normaliseEmailBrand(value) {
|
|
104
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Email branding must be an object.');
|
|
105
|
+
const out = {};
|
|
106
|
+
for (const key of ['name', 'logo', 'accent', 'supportEmail', 'footer']) {
|
|
107
|
+
if (value[key] != null && typeof value[key] !== 'string') throw new Error(`Email branding ${key} must be text.`);
|
|
108
|
+
out[key] = clean(value[key], key === 'footer' ? 600 : key === 'logo' ? 2000 : 160);
|
|
109
|
+
}
|
|
110
|
+
if (out.accent && !hex(out.accent)) throw new Error('Email accent must be a six-digit hex colour, such as #2563eb.');
|
|
111
|
+
if (/\.svg(?:[?#]|$)/i.test(out.logo)) throw new Error('Choose a PNG, JPEG, GIF or WebP email logo.');
|
|
112
|
+
if (out.logo && !/^(https?:\/\/|\/[^/])/i.test(out.logo)) throw new Error('Email logo must be an http(s) address or a site-relative path.');
|
|
113
|
+
if (out.logo && /^https?:/i.test(out.logo) && !emailUrl(out.logo)) throw new Error('Email logo address is invalid.');
|
|
114
|
+
if (out.supportEmail && !/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(out.supportEmail)) throw new Error('Email support address is invalid.');
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Public web URLs only. A relative asset needs a configured, trusted site origin. */
|
|
119
|
+
export function emailUrl(value, base) {
|
|
120
|
+
if (typeof value !== 'string' || !value.trim() || /[\u0000-\u0020\u007f]/.test(value.trim())) return '';
|
|
121
|
+
if (!/^https?:\/\//i.test(value) && !(base && /^(\/[^/]|#\/)/.test(value))) return '';
|
|
122
|
+
try {
|
|
123
|
+
const url = new URL(value, base || undefined);
|
|
124
|
+
return ['https:', 'http:'].includes(url.protocol) && !url.username && !url.password ? url.href : '';
|
|
125
|
+
} catch { return ''; }
|
|
126
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Synthetic examples only: opening the gallery never creates records or sends mail. */
|
|
2
|
+
import {brandEmail, emailBrand} from './emailBrand.js';
|
|
3
|
+
export const EMAIL_EXAMPLES = [
|
|
4
|
+
{id: 'test', label: 'SMTP and branding check', subject: 'Your email is ready to send', blocks: [{text: 'This is a test email sent from your site to check its SMTP configuration and email identity.'}, {type: 'status', text: 'SMTP connection accepted this test'}, {text: 'No accounts, bookings or orders were created.'}]},
|
|
5
|
+
{id: 'account', label: 'Account invitation', subject: 'Welcome - your account is ready', blocks: [
|
|
6
|
+
{text: 'Hi Darryl, an administrator has invited you to join the team.'},
|
|
7
|
+
{type: 'details', rows: [['Account', 'darryl@example.com'], ['Access', 'Team member'], ['Invitation expires', 'In 7 days']]},
|
|
8
|
+
{type: 'action', label: 'Set up your account', path: '/admin/'}, {text: 'This is a preview. No account or password link has been created.'}]},
|
|
9
|
+
{id: 'waypoint', label: 'Waypoint update', subject: 'Alex mentioned you in WEB-142', blocks: [
|
|
10
|
+
{type: 'details', rows: [['Project', 'Website refresh'], ['Issue', 'WEB-142 - Homepage design'], ['Updated by', 'Alex Morgan']]},
|
|
11
|
+
{type: 'quote', text: 'The revised design is ready. Darryl, could you take a look before we start building?'},
|
|
12
|
+
{type: 'action', label: 'Open issue', path: '/admin/#/plugins/waypoint-pro'}, {text: 'You received this because you watch this issue or were mentioned.'}]},
|
|
13
|
+
{id: 'booking', label: 'Booking confirmation', subject: 'Your appointment is confirmed', blocks: [
|
|
14
|
+
{type: 'status', text: 'Confirmed - we look forward to seeing you'},
|
|
15
|
+
{type: 'details', rows: [['Appointment', 'Design consultation'], ['When', 'Tuesday 24 November, 10:00-10:30 GMT'], ['Where', 'Online'], ['Reference', 'DEMO-1042']]},
|
|
16
|
+
{type: 'action', label: 'View booking', path: '/admin/'}, {text: 'Sample booking only. No appointment has been made.'}]},
|
|
17
|
+
{id: 'shop', label: 'Order confirmation', subject: 'Thank you - order #1042 is confirmed', blocks: [
|
|
18
|
+
{text: 'Hi Darryl, we have received your order and will let you know when it is ready.'},
|
|
19
|
+
{type: 'details', rows: [['Order', '#1042'], ['Items', '2 × Notebook'], ['Total paid', '£24.00'], ['Delivery', 'Standard delivery']]},
|
|
20
|
+
{type: 'action', label: 'View order', path: '/admin/'}]},
|
|
21
|
+
{id: 'report', label: 'Digest and report', subject: 'Your weekly project summary', blocks: [
|
|
22
|
+
{text: 'Here is what happened across your projects this week.'},
|
|
23
|
+
{type: 'details', rows: [['Completed', '8 issues'], ['Ready for review', '3 issues'], ['Upcoming', '2 milestones']]},
|
|
24
|
+
{type: 'items', items: ['Website refresh: homepage ready for review', 'Customer portal: sign-in improvements completed', 'Launch planning: next milestone is Friday']},
|
|
25
|
+
{type: 'action', label: 'Open projects', path: '/admin/#/plugins/waypoint-pro'}]},
|
|
26
|
+
{id: 'campaign', label: 'Campaign and invitation', subject: 'Something new for you', blocks: [
|
|
27
|
+
{text: 'Hi Darryl, we have an update we think you will enjoy.'},
|
|
28
|
+
{type: 'quote', text: 'Your own campaign content, imagery and wording stay yours. The site identity supplies the shared frame.'},
|
|
29
|
+
{type: 'action', label: 'Take a look', path: '/'}, {text: 'Preview only. Real campaign messages retain their unsubscribe links and headers.'}]}
|
|
30
|
+
];
|
|
31
|
+
export function emailExample(id, site) {
|
|
32
|
+
const example = EMAIL_EXAMPLES.find(item => item.id === id);
|
|
33
|
+
if (!example) return null;
|
|
34
|
+
const base = emailBrand(site).base;
|
|
35
|
+
const blocks = example.blocks.map(block => block.path ? {...block, url: base ? new URL(block.path, base).href : ''} : block);
|
|
36
|
+
return brandEmail({subject: example.subject}, {site, family: example.id, blocks});
|
|
37
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addresses for [map pins] - looked up when a page is SAVED, never while one renders.
|
|
3
|
+
*
|
|
4
|
+
* A save hands its body to `queueMapAddresses()`: every address in a [map pins] tag that
|
|
5
|
+
* is not already known is looked up with OpenStreetMap's Nominatim, one a second (its
|
|
6
|
+
* usage policy), in the background, and kept in content/map-places.json. When the
|
|
7
|
+
* lookups finish, the page's cache entry is dropped so the next visitor gets the pins.
|
|
8
|
+
* Rendering reads only what is kept (`placeFor()`, synchronous), so a page never waits
|
|
9
|
+
* on a lookup and a visitor's request never reaches Nominatim.
|
|
10
|
+
*
|
|
11
|
+
* Only the server talks to Nominatim, through safeFetch, and only with the address text.
|
|
12
|
+
* OFF unless the site switches it on (Site Settings > General > Maps; site.json
|
|
13
|
+
* `maps.lookupAddresses: true`) - it is a call to a third party.
|
|
14
|
+
*/
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import {config, getConfig} from '../config.js';
|
|
18
|
+
import {safeFetch} from './outbound.js';
|
|
19
|
+
import * as cache from './cache/index.js';
|
|
20
|
+
import {mapAddresses} from './mapPins.js';
|
|
21
|
+
|
|
22
|
+
const STORE_PATH = path.join(config.content.contentDir, 'map-places.json');
|
|
23
|
+
const NOMINATIM = 'https://nominatim.openstreetmap.org/search';
|
|
24
|
+
/** Nominatim's policy: at most one request a second. */
|
|
25
|
+
const GAP_MS = 1100;
|
|
26
|
+
/** An address that was not found is tried again on a save this long after. */
|
|
27
|
+
const MISS_RETRY_MS = 24 * 60 * 60 * 1000;
|
|
28
|
+
/** The most addresses one store keeps; the oldest go first. */
|
|
29
|
+
const MAX_PLACES = 5000;
|
|
30
|
+
|
|
31
|
+
/** The key an address is kept under: case and spacing do not matter. */
|
|
32
|
+
export const addressKey = (a) => String(a ?? '').toLowerCase().replace(/\s+/g, ' ').trim();
|
|
33
|
+
|
|
34
|
+
let places = null;
|
|
35
|
+
let storePath = STORE_PATH;
|
|
36
|
+
let fetcher = (url, opts) => safeFetch(url, opts);
|
|
37
|
+
let gapMs = GAP_MS;
|
|
38
|
+
let enabledOverride = null;
|
|
39
|
+
|
|
40
|
+
/** Whether this site looks addresses up (Site Settings; off unless switched on). */
|
|
41
|
+
export function addressLookupsOn() {
|
|
42
|
+
if (enabledOverride !== null) return enabledOverride;
|
|
43
|
+
try { return getConfig('site')?.maps?.lookupAddresses === true; } catch { return false; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function load() {
|
|
47
|
+
if (places) return places;
|
|
48
|
+
try {
|
|
49
|
+
const raw = JSON.parse(fs.readFileSync(storePath, 'utf8'));
|
|
50
|
+
places = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
|
|
51
|
+
} catch {
|
|
52
|
+
places = {};
|
|
53
|
+
}
|
|
54
|
+
return places;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function save() {
|
|
58
|
+
const all = Object.entries(load());
|
|
59
|
+
const kept = all.length > MAX_PLACES
|
|
60
|
+
? Object.fromEntries(all.sort((a, b) => String(b[1].at).localeCompare(String(a[1].at))).slice(0, MAX_PLACES))
|
|
61
|
+
: places;
|
|
62
|
+
places = kept;
|
|
63
|
+
const tmp = `${storePath}.${process.pid}.tmp`;
|
|
64
|
+
await fs.promises.writeFile(tmp, JSON.stringify(kept, null, 2), 'utf8');
|
|
65
|
+
await fs.promises.rename(tmp, storePath);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Where an address is, from what is kept: `{lat, lon}`, or null (not looked up yet, or not found).
|
|
70
|
+
*
|
|
71
|
+
* @param {string} address
|
|
72
|
+
*/
|
|
73
|
+
export function placeFor(address) {
|
|
74
|
+
const p = load()[addressKey(address)];
|
|
75
|
+
return p && Number.isFinite(p.lat) && Number.isFinite(p.lon) ? {lat: p.lat, lon: p.lon} : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Whether an address still needs looking up: never tried, or not found long enough ago. */
|
|
79
|
+
function needsLookup(address, now = Date.now()) {
|
|
80
|
+
const p = load()[addressKey(address)];
|
|
81
|
+
if (!p) return true;
|
|
82
|
+
if (Number.isFinite(p.lat)) return false;
|
|
83
|
+
return now - Date.parse(p.at || 0) > MISS_RETRY_MS;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** How this site introduces itself to Nominatim (its policy asks for an identifying User-Agent). */
|
|
87
|
+
function userAgent() {
|
|
88
|
+
let base = '';
|
|
89
|
+
try { base = String(getConfig('site')?.baseUrl || '').trim(); } catch { /* no site config */ }
|
|
90
|
+
return /^https?:\/\/[^\s]+$/i.test(base) ? `DommaCMS/1 (+${base})` : 'DommaCMS/1';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** One lookup: {lat, lon} or null. Throws when Nominatim cannot be reached. */
|
|
94
|
+
async function lookup(address) {
|
|
95
|
+
const url = `${NOMINATIM}?${new URLSearchParams({q: address, format: 'jsonv2', limit: '1'})}`;
|
|
96
|
+
const res = await fetcher(url, {headers: {'user-agent': userAgent(), accept: 'application/json'}, timeoutMs: 10000, maxBytes: 200000});
|
|
97
|
+
if (!res.ok) throw new Error(`Nominatim answered ${res.status}`);
|
|
98
|
+
const hit = (res.json() || [])[0];
|
|
99
|
+
const lat = Number(hit?.lat);
|
|
100
|
+
const lon = Number(hit?.lon);
|
|
101
|
+
return Number.isFinite(lat) && Number.isFinite(lon) && Math.abs(lat) <= 90 && Math.abs(lon) <= 180 ? {lat, lon} : null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let queue = Promise.resolve();
|
|
105
|
+
const wait = (ms) => new Promise(r => setTimeout(r, ms));
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Look up, in the background, the addresses a page body's [map pins] tags name that are
|
|
109
|
+
* not known yet. Returns the queued run's promise (tests await it; saves do not).
|
|
110
|
+
*
|
|
111
|
+
* @param {string} body - the page's Markdown
|
|
112
|
+
* @param {string} [urlPath] - the page, whose cache entry is dropped when its pins are ready
|
|
113
|
+
* @param {{log?: object}} [opts]
|
|
114
|
+
*/
|
|
115
|
+
export function queueMapAddresses(body, urlPath, {log} = {}) {
|
|
116
|
+
if (!addressLookupsOn()) return Promise.resolve({looked: 0, off: true});
|
|
117
|
+
const wanted = [...new Set(mapAddresses(body).filter(a => needsLookup(a)))];
|
|
118
|
+
if (!wanted.length) return Promise.resolve({looked: 0});
|
|
119
|
+
const run = queue.then(async () => {
|
|
120
|
+
let looked = 0;
|
|
121
|
+
for (const address of wanted) {
|
|
122
|
+
if (!needsLookup(address)) continue;
|
|
123
|
+
if (looked) await wait(gapMs);
|
|
124
|
+
try {
|
|
125
|
+
const hit = await lookup(address);
|
|
126
|
+
load()[addressKey(address)] = hit ? {...hit, at: new Date().toISOString()} : {miss: true, at: new Date().toISOString()};
|
|
127
|
+
if (!hit) log?.warn?.({address}, '[map] address not found');
|
|
128
|
+
} catch (err) {
|
|
129
|
+
log?.warn?.({address, err: err?.message}, '[map] address lookup failed');
|
|
130
|
+
}
|
|
131
|
+
looked++;
|
|
132
|
+
}
|
|
133
|
+
await save();
|
|
134
|
+
if (urlPath) await cache.invalidateTags([`page:${urlPath}`]).catch(() => {});
|
|
135
|
+
return {looked};
|
|
136
|
+
});
|
|
137
|
+
queue = run.catch(() => {});
|
|
138
|
+
return run;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Look up every page's [map pins] addresses - when the switch is turned on, so pages saved
|
|
143
|
+
* while it was off get their pins without being saved again. One queue, so still one a second.
|
|
144
|
+
*
|
|
145
|
+
* @param {{urlPath: string, content: string}[]} pages
|
|
146
|
+
*/
|
|
147
|
+
export function queueAllPages(pages, opts = {}) {
|
|
148
|
+
return Promise.all((pages || []).map(p => queueMapAddresses(p.content, p.urlPath, opts)));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Tests: a store file, a fetch, a gap and the switch of their own; nothing resets. */
|
|
152
|
+
export function _setGeocodeForTests({store, fetch, gap, enabled} = {}) {
|
|
153
|
+
enabledOverride = enabled ?? null;
|
|
154
|
+
places = null;
|
|
155
|
+
storePath = store ?? STORE_PATH;
|
|
156
|
+
fetcher = fetch ?? ((url, opts) => safeFetch(url, opts));
|
|
157
|
+
gapMs = gap ?? GAP_MS;
|
|
158
|
+
}
|
|
@@ -429,7 +429,7 @@ export async function sendCallEmail({to, name, hostName, joinUrl}, {log} = {}) {
|
|
|
429
429
|
if (!isSmtpConfigured(smtp)) return false;
|
|
430
430
|
const k = JSON.stringify([smtp.host, smtp.port, smtp.user, smtp.secure]);
|
|
431
431
|
if (!transport || transportFor !== k) { transport = await createTransport(smtp); transportFor = k; }
|
|
432
|
-
await sendEmail(transport, {from: smtp.fromAddress || 'noreply@example.com', fromName: smtp.fromName || s.title || 'Calls', ...msg});
|
|
432
|
+
await sendEmail(transport, {branding: {family: 'calendar'}, from: smtp.fromAddress || 'noreply@example.com', fromName: smtp.fromName || s.title || 'Calls', ...msg});
|
|
433
433
|
return true;
|
|
434
434
|
} catch (err) {
|
|
435
435
|
const line = `[calls] Email to ${to} not sent: ${err?.message || err}`;
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* page carries its own Content-Security-Policy, so the tile host is allowed
|
|
8
8
|
* there and nowhere else on the site.
|
|
9
9
|
*
|
|
10
|
-
* Pins are coordinates
|
|
11
|
-
*
|
|
12
|
-
* pins="51.5034,-0.1276 Downing Street |
|
|
10
|
+
* Pins are coordinates or addresses. Addresses are looked up when the page is
|
|
11
|
+
* saved (services/geocode.js), never while it renders or by a visitor's browser:
|
|
12
|
+
* pins="51.5034,-0.1276 Downing Street | Office = SW1A 2AA | 1 Main St, York"
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/** The most pins one map takes, and the longest label. */
|
|
@@ -22,30 +22,64 @@ const LEAFLET_CSS_SRI = 'sha384-sHL9NAb7lN7rfvG5lfHpm643Xkcjzp4jFvuavGOndn6pjVqS
|
|
|
22
22
|
const TILES = 'https://tile.openstreetmap.org';
|
|
23
23
|
|
|
24
24
|
const PIN_RE = /^([-+]?\d{1,3}(?:\.\d+)?)\s*,\s*([-+]?\d{1,3}(?:\.\d+)?)(?:\s+(.*))?$/;
|
|
25
|
+
const COORDS_RE = /^([-+]?\d{1,3}(?:\.\d+)?)\s*,\s*([-+]?\d{1,3}(?:\.\d+)?)$/;
|
|
26
|
+
/** The longest address a pin takes. */
|
|
27
|
+
export const MAX_ADDRESS = 200;
|
|
28
|
+
|
|
29
|
+
const clean = (v, max) => String(v ?? '').replace(/[\u0000-\u001f\u007f]/g, '').replace(/\s+/g, ' ').trim().slice(0, max);
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
|
-
* Read a pins attribute
|
|
32
|
+
* Read a pins attribute. Each pin, split by `|`, is one of:
|
|
33
|
+
* `lat,lon Label` - coordinates, then an optional label
|
|
34
|
+
* `Label = lat,lon` - the same, label first
|
|
35
|
+
* `Label = an address` - an address (looked up when the page is saved; services/geocode.js)
|
|
36
|
+
* `an address` - an address, which is also its label
|
|
37
|
+
* Addresses only when `addresses` is set - /_map takes coordinates alone.
|
|
28
38
|
*
|
|
29
39
|
* @param {string} value
|
|
30
|
-
* @
|
|
40
|
+
* @param {{addresses?: boolean}} [opts]
|
|
41
|
+
* @returns {{pins: ({lat: number, lon: number, label: string}|{address: string, label: string})[], error?: string}}
|
|
31
42
|
*/
|
|
32
|
-
export function parsePins(value) {
|
|
43
|
+
export function parsePins(value, {addresses = false} = {}) {
|
|
33
44
|
const parts = String(value ?? '').split('|').map(s => s.trim()).filter(Boolean);
|
|
34
|
-
|
|
45
|
+
const how = addresses ? 'latitude,longitude or an address' : 'latitude,longitude';
|
|
46
|
+
if (!parts.length) return {pins: [], error: `Add at least one pin: ${how}, with an optional label.`};
|
|
35
47
|
if (parts.length > MAX_PINS) return {pins: [], error: `A map takes up to ${MAX_PINS} pins.`};
|
|
36
48
|
const pins = [];
|
|
37
49
|
for (const part of parts) {
|
|
50
|
+
let lat; let lon; let label = ''; let address = '';
|
|
38
51
|
const m = PIN_RE.exec(part);
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
if (m) {
|
|
53
|
+
[lat, lon, label] = [Number(m[1]), Number(m[2]), m[3]];
|
|
54
|
+
} else {
|
|
55
|
+
const eq = part.indexOf('=');
|
|
56
|
+
const place = (eq >= 0 ? part.slice(eq + 1) : part).trim();
|
|
57
|
+
label = eq >= 0 ? part.slice(0, eq) : '';
|
|
58
|
+
const c = COORDS_RE.exec(place);
|
|
59
|
+
if (c) [lat, lon] = [Number(c[1]), Number(c[2])];
|
|
60
|
+
else if (addresses && place) address = clean(place, MAX_ADDRESS);
|
|
61
|
+
else return {pins: [], error: `Each pin is ${how}, with an optional label.`};
|
|
62
|
+
if (address && !label.trim()) label = address;
|
|
63
|
+
}
|
|
64
|
+
label = clean(label, MAX_LABEL);
|
|
65
|
+
if (address) { pins.push({address, label}); continue; }
|
|
42
66
|
if (Math.abs(lat) > 90 || Math.abs(lon) > 180) return {pins: [], error: 'Map pin coordinates are outside the valid range.'};
|
|
43
|
-
const label = String(m[3] ?? '').replace(/[\u0000-\u001f\u007f]/g, '').trim().slice(0, MAX_LABEL);
|
|
44
67
|
pins.push({lat, lon, label});
|
|
45
68
|
}
|
|
46
69
|
return {pins};
|
|
47
70
|
}
|
|
48
71
|
|
|
72
|
+
/** Every address the [map pins] tags in a page body name (what a save looks up). */
|
|
73
|
+
export function mapAddresses(body) {
|
|
74
|
+
const out = [];
|
|
75
|
+
const re = /\[map(?=[\s/\]])[^\]]*?\bpins\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
|
|
76
|
+
for (const m of String(body ?? '').matchAll(re)) {
|
|
77
|
+
const {pins} = parsePins(m[1] ?? m[2], {addresses: true});
|
|
78
|
+
for (const p of pins) if (p.address) out.push(p.address);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
|
|
49
83
|
/** The pins back as an attribute value (what /_map is given). */
|
|
50
84
|
export const pinsToString = (pins) => pins.map(p => `${p.lat},${p.lon}${p.label ? ' ' + p.label : ''}`).join(' | ');
|
|
51
85
|
|
|
@@ -4,6 +4,7 @@ import {decodeMessageAttribute} from '../../public/js/celebrations/message-attrs
|
|
|
4
4
|
* Parses frontmatter with gray-matter and renders Markdown to HTML with marked.
|
|
5
5
|
*/
|
|
6
6
|
import {parsePins, pinsToString} from './mapPins.js';
|
|
7
|
+
import {addressLookupsOn, placeFor} from './geocode.js';
|
|
7
8
|
import {normaliseBackground, backgroundStyle} from '../../public/js/background-style.mjs';
|
|
8
9
|
import {cssClasses} from '../../public/js/css-classes.mjs';
|
|
9
10
|
import matter from 'gray-matter';
|
|
@@ -4963,13 +4964,21 @@ function mapFigure(attrs, src, titleText, below) {
|
|
|
4963
4964
|
}
|
|
4964
4965
|
|
|
4965
4966
|
/**
|
|
4966
|
-
* [map pins="lat,lon Label |
|
|
4967
|
-
* (OpenStreetMap; services/mapPins.js).
|
|
4967
|
+
* [map pins="lat,lon Label | Label = address | ..."] - several pins, on this site's own /_map page
|
|
4968
|
+
* (OpenStreetMap; services/mapPins.js). Addresses are read from services/geocode.js's store, filled when the
|
|
4969
|
+
* page is saved; a renderer never looks one up. Every pin is in view unless a zoom is given; with
|
|
4968
4970
|
* directions, each pin's popup links to Google's route planner.
|
|
4969
4971
|
*/
|
|
4970
4972
|
function renderPinsMap(attrs) {
|
|
4971
|
-
const {pins, error} = parsePins(attrs.pins);
|
|
4972
|
-
if (error) return _embedBlocked(error);
|
|
4973
|
+
const {pins: asked, error} = parsePins(attrs.pins, {addresses: true});
|
|
4974
|
+
if (error) return _embedBlocked(escapeAttr(error));
|
|
4975
|
+
// Addresses come from what the page's save looked up (services/geocode.js); one not found yet is left off.
|
|
4976
|
+
const pins = asked.map(p => (p.address ? (placeFor(p.address) ? {...placeFor(p.address), label: p.label} : null) : p)).filter(Boolean);
|
|
4977
|
+
if (!pins.length) {
|
|
4978
|
+
return _embedBlocked(addressLookupsOn()
|
|
4979
|
+
? 'This map's addresses have not been found yet. They are looked up when the page is saved - give it a minute, or check the addresses.'
|
|
4980
|
+
: 'Map pins by address need Address look-ups switched on in Site Settings > General. Or give each pin latitude,longitude.');
|
|
4981
|
+
}
|
|
4973
4982
|
const params = new URLSearchParams({pins: pinsToString(pins)});
|
|
4974
4983
|
const parsedZoom = Number.parseInt(attrs.zoom, 10);
|
|
4975
4984
|
if (Number.isFinite(parsedZoom)) params.set('zoom', String(Math.max(1, Math.min(19, parsedZoom))));
|
|
@@ -406,7 +406,7 @@ async function send(user, origin, log) {
|
|
|
406
406
|
const message = buildResetEmail({name: user.name, link: resetLink(trusted, token), lifetime: resetLifetime().text,
|
|
407
407
|
siteTitle: site.title});
|
|
408
408
|
const transport = await mailer.createTransport(smtp);
|
|
409
|
-
await mailer.sendEmail(transport, {...fromOf(site), to: user.email, ...message});
|
|
409
|
+
await mailer.sendEmail(transport, {branding: {family: 'account'}, ...fromOf(site), to: user.email, ...message});
|
|
410
410
|
return {sent: true, reason: 'sent'};
|
|
411
411
|
}
|
|
412
412
|
|
|
@@ -451,7 +451,7 @@ export async function adminReset({user, origin, via, by}) {
|
|
|
451
451
|
const message = buildResetEmail({name: user.name, link, lifetime: expiresIn, siteTitle: site.title,
|
|
452
452
|
requestedBy: by?.name || by?.email || true});
|
|
453
453
|
const transport = await mailer.createTransport(site.smtp);
|
|
454
|
-
await mailer.sendEmail(transport, {...fromOf(site), to: user.email, ...message});
|
|
454
|
+
await mailer.sendEmail(transport, {branding: {family: 'account'}, ...fromOf(site), to: user.email, ...message});
|
|
455
455
|
return {sent: true, expiresAt, expiresIn};
|
|
456
456
|
}
|
|
457
457
|
|
|
@@ -508,7 +508,7 @@ export async function adminInvite({user, origin, by}) {
|
|
|
508
508
|
const message = buildInviteEmail({name: user.name, email: user.email, link: resetLink(origin, token), lifetime: INVITE_LIFETIME.text,
|
|
509
509
|
siteTitle: site.title, invitedBy: by === true ? '' : (by?.name || by?.email || '')});
|
|
510
510
|
const transport = await mailer.createTransport(site.smtp);
|
|
511
|
-
await mailer.sendEmail(transport, {...fromOf(site), to: user.email, ...message});
|
|
511
|
+
await mailer.sendEmail(transport, {branding: {family: 'account'}, ...fromOf(site), to: user.email, ...message});
|
|
512
512
|
return {sent: true, expiresAt, expiresIn: INVITE_LIFETIME.text};
|
|
513
513
|
}
|
|
514
514
|
|
|
@@ -555,7 +555,7 @@ export async function passwordChangedNotice({userId, by}) {
|
|
|
555
555
|
const message = buildChangedEmail({name: user.name, how, when, siteTitle: site.title,
|
|
556
556
|
signInUrl: origin ? `${origin}/admin/#/login` : ''});
|
|
557
557
|
const transport = await mailer.createTransport(site.smtp);
|
|
558
|
-
await mailer.sendEmail(transport, {...fromOf(site), to: user.email, ...message});
|
|
558
|
+
await mailer.sendEmail(transport, {branding: {family: 'security'}, ...fromOf(site), to: user.email, ...message});
|
|
559
559
|
return {sent: true, reason: 'sent'};
|
|
560
560
|
}
|
|
561
561
|
|