Sponsor invite emails for other network sites (siteinvite.js): Video App Income sponsors can email their own directs once, sent here (Marty approved 2026-11-20: directs only, fixed wording, IAP sends it). Signed /api/partner/invite/{eligible,send} (SITE_INVITE_SECRET), once ever per recipient per site, 25 a day per sender and 200 a day overall, pause switch siteInvitesPaused, the tank batches' never-mail list, no email address leaves this app; admin view + one sample to the admin address; chatbot answer; KNOWLEDGE_DATE 2026-11-21; qa/site-invite.test.mjs (39 checks)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-21 06:38:23 -06:00
parent 68825e694e
commit 1d5dd057e0
5 changed files with 336 additions and 1 deletions
+21
View File
@@ -58,6 +58,7 @@ const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed
const lsreport = require('./lsreport'); // conversion linkage: the LinkSpin click on the account, sign-up / wallet / purchase reported, reporting only (2026-11-07)
const lsinbound = require('./lsinbound'); // reverse registry sync: LinkSpin-first members arrive as waiting accounts (2026-10-15)
const tankbatch = require('./tankbatch'); // holding tank batches (2026-11-15): switch tankBatches, default off
const siteinvite = require('./siteinvite'); // sponsor invite emails for other network sites (Video App Income, Marty approved 2026-11-20): signed eligible / send, needs SITE_INVITE_SECRET
const draftpartner = require('./draftpartner'); // 5xYourTeam The Draft: signed pool / adopt / release / status on the network tank (2026-11-15, needs DRAFT_PARTNER_SECRET)
const loginClock = require('./loginadclock'); // login ads on a clock, not only at sign-in (Marty 2026-11-15): see loginadclock.js
const erase = require('./erase'); // member erase (2026-11-15, LS-1021): POST /api/admin/erase + the hub's member.erased event
@@ -872,6 +873,11 @@ async function boot() {
let jpeg = null; try { jpeg = fs.readFileSync(path.join(__dirname, 'public', 'banners', 'holding-tank-leads-1200x675.jpg')); } catch (e) {}
if (jpeg && html.length <= 1024 && await telegramSendPhoto(chat, jpeg, html, topic)) return; await telegramSend(chat, html, topic); },
feed: async (who, what, level) => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return; const clean = t => String(t || '').replace(/[<>&]/g, ''); await telegramSend(sc.telegramEchoChatId, '\u{1F91D} <b>InstantAdPay</b> · <b>' + clean(who) + '</b> just received ' + clean(what) + ' from the holding tank (' + clean(level) + ' level)', sc.telegramEchoTopicId); } } }).catch(e => console.error('tankbatch init', e.message)); }
// sponsor invite emails for other network sites (siteinvite.js, 2026-11-21): the same never-mail list the tank batches use
{ let spamC = { at: 0, set: new Set() }; const spamSet = () => { if (Date.now() - spamC.at > 60000) { try { spamC = { at: Date.now(), set: new Set((((spamscan.view() || {}).last || {}).candidates || []).map(c => String(c.email || '').toLowerCase())) }; } catch (e) { spamC = { at: Date.now(), set: new Set() }; } } return spamC.set; };
await siteinvite.init({ dataDir: DATA_DIR, accounts, mailer, siteConfig, prohibited,
hooks: { excluded: em => fraud.excluded(em),
excludedPerson: async em => { if (spamSet().has(em)) return 'spam scan'; const d = String(em).split('@')[1] || ''; const fix = require('./emailcheck').suggestDomain(d); if (fix && fix !== d) return 'mistyped email domain'; if (erase.isErased(em)) return 'erased'; if (await drip.isUnsubscribed(em).catch(() => false)) return 'unsubscribed from email'; return null; } } }).catch(e => console.error('siteinvite init', e.message)); }
setTimeout(() => tankbatch.tick().catch(e => console.error('tankbatch', e.message)), 4 * 60 * 1000); // past the deploy overlap window
setInterval(() => tankbatch.tick().catch(e => console.error('tankbatch', e.message)), 60 * 60 * 1000);
setInterval(() => tankbatch.mailTick().catch(e => console.error('tankbatch mail', e.message)), 60 * 1000); // throttled batch emails (tankBatchEmailsPerDay, 8 AM to 8 PM CT) + spaced Telegram cards
@@ -950,6 +956,7 @@ function siteConfig() {
loginAdEveryHours: 3, // login ad: shown again on the next member page once the last finished view is this many hours old (Marty 2026-11-15)
tankAdoptCap: 10, // holding tank: people one adopter may hold at one time (not yet switched on payouts), Marty 2026-11-11
fiveXDraftCap: 10, // 5xYourTeam draft: open picks one coach may hold, its own cap (Marty 2026-11-15), never shared with tankAdoptCap or batches
...siteinvite.DEFAULTS, // sponsor invite emails for other network sites (siteinvite.js): siteInvitesPaused '1' stops them; per-sender and all-senders daily caps
...tankbatch.DEFAULTS, // holding tank batches (tankbatch.js, Marty 2026-11-15): master switch tankBatches '0'; every number of the ladder, cadence and follow-up
legacyCreditsAdvertiser: 500, legacyCreditsEarner: 150, // welcome-back credits for listed Faucet Wave / Tier One Ads emails arriving via /from/<brand>
geoTier1: '', // comma-separated ISO country codes; empty = built-in default (US, CA, GB, AU, NZ, IE, DE, FR, NL, SE, NO, DK, FI, CH, AT, BE)
@@ -3924,6 +3931,20 @@ const server = http.createServer(async (req, res) => {
const r = await draftpartner.handle(op, sg.body);
return json(res, r.error ? 400 : 200, r);
}
// -- sponsor invite emails for other network sites (siteinvite.js, 2026-11-21): signed partner calls, SITE_INVITE_SECRET as X-Invite-Ts + X-Invite-Sig
if (p.startsWith('/api/partner/invite/') && req.method === 'POST') {
const raw = await new Promise((ok, no) => { let d = ''; req.on('data', c => { d += c; if (d.length > 64000) { req.destroy(); no(new Error('too big')); } }); req.on('end', () => ok(d)); req.on('error', no); });
const sg = siteinvite.verify(req.headers, raw); if (!sg.body) return json(res, sg.status, { error: sg.error });
const op = p.slice('/api/partner/invite/'.length);
if (!['eligible', 'send'].includes(op)) return json(res, 404, { error: 'unknown op' });
const r = await siteinvite.handle(op, sg.body);
return json(res, r.error ? 400 : 200, r);
}
if (p === '/api/admin/site-invites' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await siteinvite.adminView()); }
if (p === '/api/admin/site-invites/sample' && req.method === 'POST') { // one sample of the invite email to the admin address only
if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); if (!ADMIN_EMAIL) return json(res, 400, { error: 'no admin email set' });
return json(res, 200, await siteinvite.sample(ADMIN_EMAIL, 'videoappincome'));
}
if (p === '/api/admin/draft' && req.method === 'GET') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
return json(res, 200, await draftpartner.adminView());