diff --git a/coach.js b/coach.js index 896e419..a97c45a 100644 --- a/coach.js +++ b/coach.js @@ -56,12 +56,16 @@ async function member(id) { const STALL_DAYS = 3; async function describe(acct, now = Date.now()) { const mm = await member(acct.memberId); + // unknown = the member is on chain but the read failed just now (member() swallows RPC errors and caches null for a + // minute); rungFor would call them "payouts on, no purchase" and the coach would mail a buyer the first-package nudge + // (2026-10-31: Marty, 4 purchases and 7 buyers, got "See a payout land"). Callers that mail must skip unknown. + const unknown = !!(acct.memberId && !mm); const rung = rungFor(acct, mm); const last = Math.max(acct.created || 0, acct.lastSeen || 0); const quietDays = Math.floor((now - last) / DAY); - const stalled = rung < 6 && quietDays >= STALL_DAYS; + const stalled = !unknown && rung < 6 && quietDays >= STALL_DAYS; const R = RUNGS[rung]; - return { rung, label: R.label, next: R.next, say: R.say, quietDays, stalled, buyerCount: mm ? mm.buyerCount : 0, + return { rung, label: R.label, next: R.next, say: R.say, quietDays, stalled, unknown, buyerCount: mm ? mm.buyerCount : 0, counted: !!(mm && mm.countedAsBuyer), joined: acct.created, lastSeen: acct.lastSeen || 0, onchainSponsorId: mm ? mm.sponsorId : null }; } // coaching view for a sponsor: every direct, ladder rung, stalled flag, what to say @@ -221,6 +225,7 @@ async function nudgeTick() { const all = await accounts.listAll(5000); for (const acct of all) { if (!acct.email || !acct.created || now - acct.created < STALL_DAYS * DAY) continue; + if (X.adminEmail && String(acct.email).toLowerCase() === String(X.adminEmail).toLowerCase()) continue; // the site owner is never coached (2026-10-31) if (!acct.lastSeen || acct.joinedVia === 'carried' && !acct.lastSeen) continue; // never signed in here (carried-over shells from InstantAdPay): no coaching mail, ever (2026-10-11: Harvey got a nudge for a site he never joined) const c = await describe(acct, now); if (!c.stalled) continue; diff --git a/server.js b/server.js index 452ff4e..81b4b9d 100644 --- a/server.js +++ b/server.js @@ -670,7 +670,7 @@ async function boot() { setTimeout(() => refill.tick().catch(e => console.error('refill', e.message)), 90000); setInterval(() => refill.tick().catch(e => console.error('refill', e.message)), 20 * 60 * 1000); // follow-up email sequence: send whatever came due (every 10 min, first pass shortly after boot) - coach.init({ dataDir: DATA_DIR, chain, accounts, mailer, ads, tank, lb: () => leaderboard, siteConfig }); + coach.init({ dataDir: DATA_DIR, chain, accounts, mailer, ads, tank, lb: () => leaderboard, siteConfig, adminEmail: ADMIN_EMAIL }); pipeline.init({ dataDir: DATA_DIR, accounts, coach, chain }); registry.init({ dataDir: DATA_DIR }); carry.init({ dataDir: DATA_DIR, accounts, registry, chain, mailer, messages, siteConfig, adminEmail: ADMIN_EMAIL, host: SITE_HOST,