← back to George Gmail
George: make the 'From job:' provenance banner opt-out (no_source_tag flag / x-george-no-tag header) so customer-facing sends can be banner-free
ab70d2e407c27a9165982430c133c9133fff2827 · 2026-05-19 10:38:59 -0700 · Steve Abrams
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
A patch-no-source-tag.jsM server.js
Diff
commit ab70d2e407c27a9165982430c133c9133fff2827
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue May 19 10:38:59 2026 -0700
George: make the 'From job:' provenance banner opt-out (no_source_tag flag / x-george-no-tag header) so customer-facing sends can be banner-free
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
patch-no-source-tag.js | 40 ++++++++++++++++++++++++++++++++++++++++
server.js | 3 +++
2 files changed, 43 insertions(+)
diff --git a/patch-no-source-tag.js b/patch-no-source-tag.js
new file mode 100644
index 0000000..e02d605
--- /dev/null
+++ b/patch-no-source-tag.js
@@ -0,0 +1,40 @@
+#!/usr/bin/env node
+/**
+ * Makes George's "From job:" provenance banner OPT-OUT.
+ * After patching, any request that sends `no_source_tag: true` in its JSON body
+ * (or header `x-george-no-tag`) gets a clean message with no banner. Every other
+ * caller is unaffected — the banner still appears by default.
+ *
+ * Idempotent + safe: aborts if George's source doesn't match, backs up first.
+ * Run on the host where George is deployed:
+ * node patch-no-source-tag.js /path/to/george/server.js
+ * then: node -c server.js && pm2 restart george
+ */
+const fs = require('fs');
+const file = process.argv[2] || './server.js';
+let s = fs.readFileSync(file, 'utf8');
+
+if (s.includes('no_source_tag')) { console.log('Already patched — no change made.'); process.exit(0); }
+
+const aOld = "function inferSource(body, req) {\n const raw = body.source";
+const aNew = "function inferSource(body, req) {\n" +
+ " if (body && (body.no_source_tag || body.noSourceTag)) return '';\n" +
+ " if (req?.headers?.['x-george-no-tag']) return '';\n" +
+ " const raw = body.source";
+
+const bOld = "function withSourceFooter(htmlBody, source) {\n const ts = new Date()";
+const bNew = "function withSourceFooter(htmlBody, source) {\n" +
+ " if (!source) return htmlBody || '';\n" +
+ " const ts = new Date()";
+
+if (!s.includes(aOld) || !s.includes(bOld)) {
+ console.error('ERROR: inferSource / withSourceFooter not found as expected — deployed George differs. Aborting, nothing changed.');
+ process.exit(1);
+}
+
+const bak = file + '.bak-' + new Date().toISOString().replace(/[:.]/g, '-');
+fs.writeFileSync(bak, s);
+s = s.replace(aOld, aNew).replace(bOld, bNew);
+fs.writeFileSync(file, s);
+console.log('Patched OK. Backup saved: ' + bak);
+console.log('Next: node -c ' + file + ' && pm2 restart george');
diff --git a/server.js b/server.js
index f78e370..f06e90c 100644
--- a/server.js
+++ b/server.js
@@ -969,6 +969,8 @@ function encodeMimeHeader(s) {
// req.body.source (preferred), req.body.job, req.headers['x-george-source'],
// or falls back to the user-agent string.
function inferSource(body, req) {
+ if (body && (body.no_source_tag || body.noSourceTag)) return ''; // opt out of the From-job banner
+ if (req?.headers?.['x-george-no-tag']) return '';
const raw = body.source || body.job || body.from_job || body.origin
|| req?.headers?.['x-george-source']
|| req?.headers?.['user-agent']
@@ -976,6 +978,7 @@ function inferSource(body, req) {
return String(raw).slice(0, 120);
}
function withSourceFooter(htmlBody, source) {
+ if (!source) return htmlBody || ''; // empty source → no banner (customer-facing send)
const ts = new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angeles', month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: '2-digit' });
const tag = `<div style="font-family:ui-monospace,Menlo,monospace;font-size:10px;letter-spacing:.10em;text-transform:uppercase;color:#7a766f;padding:8px 12px;background:rgba(212,160,74,0.08);border-left:3px solid #d4a04a;margin-bottom:18px;border-radius:2px"><strong style="color:#d4a04a">From job:</strong> ${escapeHtml(source)} <span style="color:#a8a39c">·</span> ${ts}</div>`;
return tag + (htmlBody || '');
← fd1481e Fleet auto-responder: stop logging non-fleet mail to UI run-
·
back to George Gmail
·
add trash-fleet-mailtests.js — one-off cleanup of 89 fleet d c2bdfca →