Level-4 override DRY RUN: 3% of each purchase to the 4th upline with 5+ qualifying buyers, hunting upward up to 25 hops; weekly Monday report to Marty's Telegram + /api/admin/override; no money moves

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-17 10:29:52 -05:00
parent af66f7f865
commit 34d2284051
2 changed files with 103 additions and 0 deletions
+11
View File
@@ -59,6 +59,7 @@ const fridaybank = require('./fridaybank'); // Friday Bonus Hunts: days banked S
const refill = require('./refill');
const pdsync = require('./pdsync'); // PassiveDrip PTC bridge: our visit campaigns on their paid-to-click page (2026-09-30) // campaign running-low / ran-out notices, and what came of them // Five Dollar Friday: +20% credits on Friday packs, the wave, the badge (Marty, 2026-09-20)
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
const override = require('./override'); // level-4 override, DRY RUN: weekly who-would-be-paid report, no money moves (2026-10-17)
const translate = require('./translate'); // help desk: member messages in other languages, replies back in theirs (2026-10-16)
const inbound = require('./inbound'); // help desk email intake: SendGrid Inbound Parse -> tickets (2026-10-16)
const supportbot = require('./supportbot'); // @CTBTickets_bot: ticket pings with buttons + answering from Telegram (2026-10-16)
@@ -562,6 +563,8 @@ async function boot() {
telegram: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false; return telegramSend(sc.telegramEchoChatId, '\u{1F7E0} <b>InstantAdPay</b> · ' + text, sc.telegramEchoTopicId); },
notify: async (memberId, subject, text, kind) => { const a = await accounts.byMemberId(memberId); if (!a || !a.email) return; const html = '<p>' + String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(https:\/\/[^\s]+)/g, '<a href="$1" target="_blank" rel="noopener">$1</a>').split('\n\n').join('</p><p>').replace(/\n/g, '<br>') + '</p>'; await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [a.email], subject, html, kind || 'notice'); } });
setInterval(() => wednesday.tick().catch(e => console.error('wednesday', e.message)), 5 * 60 * 1000);
override.init({ dataDir: DATA_DIR, chain, siteConfig, notify: supportTelegram });
setInterval(() => override.tick().catch(e => console.error('override', e.message)), 30 * 60 * 1000);
setInterval(() => snapshot.tick().catch(e => console.error('snapshot', e.message)), 10 * 60 * 1000);
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, ads, site: 'https://instantadpay.com' });
// LinkSpin registry sync (2026-10-08): every account change is pushed to LinkSpin within seconds; a 2-minute reconcile catches the rest
@@ -4592,6 +4595,14 @@ const server = http.createServer(async (req, res) => {
if (!isAdmin(req)) return json(res, 200, { admin: false });
return json(res, 200, { admin: true, email: ADMIN_EMAIL });
}
// -- level-4 override dry run (2026-10-17): ?week=YYYY-MM-DD (any day in the week) or ?from=&to= (ms); rows=1 adds every purchase
if (p === '/api/admin/override' && req.method === 'GET') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const from = Number(u.searchParams.get('from')), to = Number(u.searchParams.get('to'));
const r = from && to ? await override.report(from, to) : await override.week(u.searchParams.get('week') || '');
if (u.searchParams.get('rows') !== '1') delete r.rows;
return json(res, 200, r, { 'Cache-Control': 'no-store' });
}
// -- help desk, admin side (2026-10-16): the Support pane
if (p === '/api/admin/support/telegram/register' && req.method === 'POST') { // point @CTBTickets_bot's webhook at this server
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });