Mail: the first non-code email to each address opens with a short 'what LinkSpin is' intro (once per address, mail-intro.json)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-18 08:43:53 -05:00
parent 7b63e75986
commit e0e0bde1f9
+22 -1
View File
@@ -25,9 +25,30 @@ function hasKey() { return OUTBOUND && !!key(); }
const MAIL_MODE = String(process.env.LS_MAIL_MODE || 'codes-only').trim();
let held = 0;
// First-email intro (Marty, 2026-10-18, when the gate opened): most people on LinkSpin were carried over from
// InstantAdPay and never asked for it, so the first non-code email anyone gets from us starts by saying what
// LinkSpin is. Once per address, kept in DATA_DIR/mail-intro.json; sign-in codes and admin alerts never carry it.
const INTRO = 'New to LinkSpin? Here is the short version.\n\n'
+ 'LinkSpin is the newest platform in the Crypto Team Build Network, from the team behind InstantAdPay. '
+ 'If you are an InstantAdPay member, your account is already here. There is nothing new to sign up for: '
+ 'sign in at ' + SITE_URL + ' with the same email you use on InstantAdPay.\n\n'
+ 'What it does: one spin link that rotates your traffic across every page you promote, bridge pages you can build in a minute, '
+ 'ad zones that earn you credits on your own sites, and ad packages from $10 to $500. Every package pays the sponsor line '
+ 'on Polygon in the same transaction. Nothing is held for later.\n\n'
+ 'We are in pre-launch testing until November 15. Everything is live and working, but details may change while we test.\n\n'
+ '----------------------------------------\n\n';
const ADMIN = String(process.env.ADMIN_EMAIL || '').trim().toLowerCase();
let introSeen = null;
const introFile = () => path.join(DATA_DIR, 'mail-intro.json');
function introLoad() { if (!introSeen) { try { introSeen = JSON.parse(fs.readFileSync(introFile(), 'utf8')); } catch (e) { introSeen = {}; } } return introSeen; }
function introMark(e) { introLoad()[e] = Date.now(); try { fs.writeFileSync(introFile() + '.tmp', JSON.stringify(introSeen)); fs.renameSync(introFile() + '.tmp', introFile()); } catch (err) {} }
function send(to, subject, text, opts) {
if (!OUTBOUND) return Promise.reject(new Error('outbound mail is off on this deployment (set OUTBOUND=on to allow it)'));
if (MAIL_MODE !== 'all' && !(opts && opts.code)) { held++; console.log('mail held (codes-only, #' + held + '): ' + String(subject).slice(0, 80)); return Promise.resolve(false); }
const toKey = String(to || '').trim().toLowerCase();
const withIntro = !(opts && opts.code) && !!toKey && toKey !== ADMIN && !introLoad()[toKey];
if (withIntro) text = INTRO + text;
return new Promise((resolve, reject) => {
const body = JSON.stringify({
personalizations: [{ to: [{ email: to }] }],
@@ -41,7 +62,7 @@ function send(to, subject, text, opts) {
res => {
let d = '';
res.on('data', c => d += c);
res.on('end', () => res.statusCode < 300 ? resolve(true) : reject(new Error('sendgrid ' + res.statusCode + ': ' + d.slice(0, 200))));
res.on('end', () => { if (res.statusCode < 300 && withIntro) introMark(toKey); return res.statusCode < 300 ? resolve(true) : reject(new Error('sendgrid ' + res.statusCode + ': ' + d.slice(0, 200))); });
});
req.on('error', reject);
req.on('timeout', () => req.destroy(new Error('sendgrid timeout')));