Hub 2.10.0: emails laid out as Events' and Accounts'; FastPanel ^~ /api/
- src/utils/emailLayout.js: one layout for every Hub email (Cross Code header with the logo, heading, button with the link under it, notes, tables, job steps, code blocks, footer), HTML and plain text from the same blocks, everything escaped. mail.sendMail attaches the logo. - Every email moved onto it: job reports, alerts, update requests, the SMTP test, notices, and all emails to site admins. Billing keeps its own. - The FastPanel email and the install page give the backend as nginx config with location ^~ /api/ (FastPanel's static-file rule took /api/...png). - Proxy done checks /api/proxy-check.png doesn't reach the frontend. - deployment.md: ^~ for the Hub's own /api/ too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,14 @@ const { getSettings } = require('../utils/settings');
|
||||
const { compareVersions } = require('../utils/alerts');
|
||||
const { requestMessage, requestedVersionOf, isOutdated } = require('../utils/updateRequests');
|
||||
const { sendMail } = require('../utils/mail');
|
||||
const { render } = require('../utils/emailLayout');
|
||||
|
||||
/** An update-request email to Joshua (2.10.0: laid out as the Hub's other emails). */
|
||||
const updateRequestEmail = ({ heading, note, rows, link }) => render({
|
||||
heading,
|
||||
blocks: [note, { rows }, { button: { label: 'Open the install', url: link } }],
|
||||
footer: 'Sent by the Cross Code Hub to the alert address in Settings.',
|
||||
});
|
||||
const { releasesForInstall, latestVersions, unmetRequirementsFor, requirementMessage } = require('../utils/releases');
|
||||
const { noticesForInstall } = require('../utils/notices');
|
||||
const ai = require('../utils/ai');
|
||||
@@ -296,7 +304,12 @@ router.post('/installs/update-request', updateRequestLimiter, async (req, res) =
|
||||
await sendMail({
|
||||
to: settings.alert_email,
|
||||
subject: `Cross Code Hub: update request changed by ${name}`,
|
||||
text: `${name} (${install.url}) now asks to be updated from ${current} to ${latest}${previous ? ` instead of ${previous}` : ''}.\n\n${link}`,
|
||||
...updateRequestEmail({
|
||||
heading: `${name} changed their update request`,
|
||||
note: { note: { kind: 'info', text: `${name} now asks to be updated to ${latest}${previous ? ` instead of ${previous}` : ''}.` } },
|
||||
rows: [['Church', name], ['Site', install.url], ['Running', current], ['Wants', latest]],
|
||||
link,
|
||||
}),
|
||||
}).catch(e => console.warn('[update-request] email failed:', e?.message));
|
||||
}
|
||||
return res.json({ requestedAt: now.toISOString(), version: latest, alreadyRequested: true, changed: true, previousVersion: previous });
|
||||
@@ -308,7 +321,12 @@ router.post('/installs/update-request', updateRequestLimiter, async (req, res) =
|
||||
await sendMail({
|
||||
to: settings.alert_email,
|
||||
subject: `Cross Code Hub: update requested by ${name}`,
|
||||
text: `${name} (${install.url}) would like to be updated from ${current} to ${latest}.\n\n${link}`,
|
||||
...updateRequestEmail({
|
||||
heading: `${name} would like an update`,
|
||||
note: { note: { kind: 'info', text: `${name} asked to be updated from ${current} to ${latest}.` } },
|
||||
rows: [['Church', name], ['Site', install.url], ['Running', current], ['Wants', latest]],
|
||||
link,
|
||||
}),
|
||||
}).catch(e => console.warn('[update-request] email failed:', e?.message));
|
||||
}
|
||||
res.status(201).json({ requestedAt: event.createdAt.toISOString(), version: latest, alreadyRequested: false, changed: false });
|
||||
@@ -338,7 +356,12 @@ router.post('/installs/update-request/cancel', updateRequestLimiter, async (req,
|
||||
await sendMail({
|
||||
to: settings.alert_email,
|
||||
subject: `Cross Code Hub: update request withdrawn by ${customer?.name || install.name}`,
|
||||
text: `${customer?.name || install.name} (${install.url}) withdrew their update request. No need to update the site for now.\n\n${(process.env.FRONTEND_URL || '').replace(/\/$/, '')}/installs/${install.id}`,
|
||||
...updateRequestEmail({
|
||||
heading: `${customer?.name || install.name} withdrew their update request`,
|
||||
note: { note: { kind: 'success', text: 'No need to update the site for now.' } },
|
||||
rows: [['Church', customer?.name || install.name], ['Site', install.url]],
|
||||
link: `${(process.env.FRONTEND_URL || '').replace(/\/$/, '')}/installs/${install.id}`,
|
||||
}),
|
||||
}).catch(e => console.warn('[update-request] email failed:', e?.message));
|
||||
}
|
||||
res.json({ cancelled: true });
|
||||
|
||||
Reference in New Issue
Block a user