diff --git a/server.js b/server.js
index 7e85bfb..823bac0 100644
--- a/server.js
+++ b/server.js
@@ -2337,7 +2337,7 @@ const server = http.createServer(async (req, res) => {
if (p === '/api/admin/updates/send' && req.method === 'POST') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const b = await readBody(req);
- const r = await updates.send({ subject: b.subject, intro: b.intro, closing: b.closing, noteIds: (b.noteIds || []).map(String), audience: b.audience, to: Array.isArray(b.to) ? b.to.slice(0, 5000) : null }, { test: !!b.test });
+ const r = await updates.send({ subject: b.subject, intro: b.intro, closing: b.closing, image: b.image, imageLink: b.imageLink, noteIds: (b.noteIds || []).map(String), audience: b.audience, to: Array.isArray(b.to) ? b.to.slice(0, 5000) : null }, { test: !!b.test });
return json(res, r.error ? 400 : 200, r);
}
if (p === '/api/admin/releases' && req.method === 'GET') {
diff --git a/tools/patch_update_image.py b/tools/patch_update_image.py
new file mode 100644
index 0000000..b01c2df
--- /dev/null
+++ b/tools/patch_update_image.py
@@ -0,0 +1,35 @@
+# Member update emails can carry ONE header image (Marty, 2026-10-03: the Spooky Doors announcement with its share image).
+# An optional https image (+ link) adds a simple HTML part next to the plain text, never instead of it: the image on
+# top (linked), the same paragraphs, the same footer and unsubscribe link. No template, so deliverability stays plain.
+ROOT = 'D:/Projects/HighRisk/onchain-ad-membership/site/'
+def edit(path, pairs):
+ b = open(ROOT + path, 'rb').read(); crlf = b.count(b'\r\n') > b.count(b'\n') // 2
+ s = b.decode('utf-8').replace('\r\n', '\n')
+ for a, r in pairs:
+ if s.count(a) != 1: raise SystemExit('%s anchor %d: %s' % (path, s.count(a), a[:70]))
+ s = s.replace(a, r)
+ if crlf: s = s.replace('\n', '\r\n')
+ open(ROOT + path, 'wb').write(s.encode('utf-8')); print('patched', path)
+
+HTML = r"""// the optional HTML twin of the plain text: one linked header image, then the same paragraphs (URLs clickable)
+const escH = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
+const okUrl = u => /^https:\/\/[^\s"'<>]+$/.test(String(u || ''));
+function toHtml(parts, image, link) {
+ const para = t => '
' + escH(t).replace(/https:\/\/[^\s<]+/g, u => '' + u + '').replace(/\n/g, '
') + '
';
+ const img = '
';
+ return ''
+ + (okUrl(link) ? '
' + img + '' : img) + parts.map(para).join('') + '
';
+}
+"""
+edit('updates.js', [
+ ("function compose({ subject, intro, noteIds, closing }, acct) {", HTML + "function compose({ subject, intro, noteIds, closing, image, imageLink }, acct) {"),
+ (" return { subject: String(subject || '').trim().slice(0, 150) || 'What is new on InstantAdPay', text: parts.join('\\n\\n') };",
+ " return { subject: String(subject || '').trim().slice(0, 150) || 'What is new on InstantAdPay', text: parts.join('\\n\\n'), html: okUrl(image) ? toHtml(parts, image, imageLink) : null };"),
+ (" await R.mailer.send(to, '[TEST] ' + m.subject, m.text);", " await R.mailer.send(to, '[TEST] ' + m.subject, m.text, m.html);"),
+ (" await R.mailer.send(acct.email, m.subject, m.text); rec.sent += 1;", " await R.mailer.send(acct.email, m.subject, m.text, m.html); rec.sent += 1;"),
+])
+edit('server.js', [
+ ("const r = await updates.send({ subject: b.subject, intro: b.intro, closing: b.closing, noteIds: (b.noteIds || []).map(String), audience: b.audience,",
+ "const r = await updates.send({ subject: b.subject, intro: b.intro, closing: b.closing, image: b.image, imageLink: b.imageLink, noteIds: (b.noteIds || []).map(String), audience: b.audience,"),
+])
+print('ok')
diff --git a/updates.js b/updates.js
index ac0f19a..df2fcf7 100644
--- a/updates.js
+++ b/updates.js
@@ -43,7 +43,16 @@ let countsSnap = null, counting = false;
async function refreshCounts() { if (counting) return; counting = true; try { countsSnap = await counts(); } catch (e) {} finally { counting = false; } }
function countsSnapshot() { if (!countsSnap && !counting) refreshCounts().catch(() => {}); return countsSnap; }
-function compose({ subject, intro, noteIds, closing }, acct) {
+// the optional HTML twin of the plain text: one linked header image, then the same paragraphs (URLs clickable)
+const escH = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
+const okUrl = u => /^https:\/\/[^\s"'<>]+$/.test(String(u || ''));
+function toHtml(parts, image, link) {
+ const para = t => '' + escH(t).replace(/https:\/\/[^\s<]+/g, u => '' + u + '').replace(/\n/g, '
') + '
';
+ const img = '
';
+ return ''
+ + (okUrl(link) ? '
' + img + '' : img) + parts.map(para).join('') + '
';
+}
+function compose({ subject, intro, noteIds, closing, image, imageLink }, acct) {
const notes = R.releases.notes().filter(n => noteIds.includes(n.id));
const name = acct && acct.username ? '@' + acct.username : 'there';
const parts = ['Hi ' + name + ','];
@@ -54,7 +63,7 @@ function compose({ subject, intro, noteIds, closing }, acct) {
parts.push('Sign in: ' + SITE + '/my');
parts.push('InstantAdPay\nAdvertise and earn instantly. Locked in code, not promises.\nNo income is guaranteed; results depend on your effort. Cryptocurrency carries risk.');
if (acct && acct.email) parts.push('Stop these update emails: ' + R.drip.unsubUrl(acct.email));
- return { subject: String(subject || '').trim().slice(0, 150) || 'What is new on InstantAdPay', text: parts.join('\n\n') };
+ return { subject: String(subject || '').trim().slice(0, 150) || 'What is new on InstantAdPay', text: parts.join('\n\n'), html: okUrl(image) ? toHtml(parts, image, imageLink) : null };
}
let running = null;
@@ -67,7 +76,7 @@ async function send(input, opts) {
const to = R.adminEmail; if (!to) return { error: 'No admin email configured.' };
const acct = (await R.accounts.byEmail(to)) || { email: to, username: null };
const m = compose(input, acct);
- await R.mailer.send(to, '[TEST] ' + m.subject, m.text);
+ await R.mailer.send(to, '[TEST] ' + m.subject, m.text, m.html);
return { ok: true, test: true, to };
}
if (running) return { error: 'A send is already running (' + running.sent + ' of ' + running.total + '). Wait for it to finish.' };
@@ -84,7 +93,7 @@ async function send(input, opts) {
try {
if (R.drip.isUnsubscribed && await R.drip.isUnsubscribed(acct.email)) { rec.skipped += 1; continue; }
const m = compose(input, acct);
- await R.mailer.send(acct.email, m.subject, m.text); rec.sent += 1; (rec.delivered = rec.delivered || []).push(acct.email);
+ await R.mailer.send(acct.email, m.subject, m.text, m.html); rec.sent += 1; (rec.delivered = rec.delivered || []).push(acct.email);
} catch (e) { rec.failed += 1; console.error('updates send', acct.email, e.message); }
if ((rec.sent + rec.failed + rec.skipped) % 10 === 0) { const l2 = log(); const k = l2.sends.find(x => x.id === rec.id); if (k) Object.assign(k, rec); saveLog(l2); }
await new Promise(r => setTimeout(r, 150));