One-tap switch on payouts after a holding-tank assignment + reminders (Marty approved 2026-10-27)

- Assignment chat + member email (manual adoption and the 24h auto-assign) carry "Switch on payouts" -> https://instantadpay.com/my?activate=1#wallet
- /my?activate=1: signed in, wallet linked, real sponsor, no hold -> Wallet tab, explainer line, the Activate button's own flow (injected wallet or the WalletConnect picker on a phone). Survives sign-in and the wallet link (sessionStorage); never starts on tankHold, a blocked/routed sponsor or the #1 fallback (/api/me sponsorFallback)
- payTick (in the 15-min readyTick): not activated 24h after the assignment -> ONE member email + ONE in-app notice to the sponsor; 72h -> last member email; stops on memberId / MemberActivated / sponsor change. State tank-ready.json `pay`, each send gated by marks.claim (deploy overlap), record saved before the send; Admin tank view gets payReminders
- Chatbot: tank-activate-link canned answer + system prompt; my.js ?v=20261027pa
- qa/tank-hold.mjs: link texts, reminder schedule on a mocked clock, overlap copy, ?activate=1 browser flows (stubbed wallet)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-27 07:29:43 -05:00
parent e5c55c2d8b
commit 59607d0c94
6 changed files with 251 additions and 23 deletions
+4 -1
View File
@@ -134,6 +134,9 @@ const CANNED = [
{ id: 'tank-hold', title: 'Matched with a sponsor (activation on hold)', q: ['Why can I not switch on payouts?', 'It says I am being matched with a sponsor'], tags: ['holding tank', 'switch on payouts', 'matched with a sponsor', 'ready to activate'],
re: /(being matched|matched with a sponsor|(can.?t|cannot|unable to) (i )?(switch on|turn on|activate) (my )?payouts|activate (button|payouts) (is )?(gone|missing|hidden)|ready to activate)/i,
a: 'You joined without a sponsor, so you are in the holding tank. The contract locks your sponsor for good the first time you switch on payouts or buy, so switching on payouts on its own waits until a real member picks you up. Buying is never held: you can buy a package any time, and with no sponsor it goes through under the company position. Once your wallet is linked, members see you at the top of their holding tank with a Ready to activate badge. If nobody adopts you within 24 hours, the site assigns you to the next eligible member in turn (someone active with their own $20 package). As soon as you have a sponsor, the Switch on payouts button comes back. If you already have a sponsor on LinkSpin with the same email or wallet, you are placed under them right away.' },
{ id: 'tank-activate-link', title: 'Switch on payouts after you were picked up (one-tap link)', q: ['I got a Switch on payouts link from my new sponsor', 'How do I switch on payouts after I was adopted?'], tags: ['holding tank', 'switch on payouts', 'adopted', 'one tap', 'reminder'],
re: /((switch on|turn on|activate) payouts? (link|email|reminder)|activate=1|(picked (me )?up|adopted( me)?).*(switch on|activate)|one.?tap.*(payouts|activate)|reminder.*switch on payouts)/i,
a: 'When a member picks you up from the holding tank (or the site assigns you to one after 24 hours), the chat and the email you get both carry a Switch on payouts link: instantadpay.com/my?activate=1#wallet. Tap it, sign in if asked, and your wallet opens with your new sponsor already filled in. It is one free transaction, no package needed, and it locks that sponsor in as yours on the contract. No wallet linked yet? The same link asks you to link one first (one free signature) and then carries on. On a phone without a wallet browser, the wallet picker opens and hands you to your wallet app to confirm. Nobody, not even the site, can switch payouts on for you: it has to come from your own wallet. If you have not done it 24 hours after you were picked up you get one reminder email (and your sponsor gets a note to give you a nudge), and one last reminder at 72 hours. They stop as soon as your payouts are on or you buy a package.' },
{ id: 'holding-tank', title: 'Holding tank and adoptions', q: ['What is the holding tank?', 'How do I adopt a member?'], tags: ['holding tank', 'adopt', 'unsponsored'],
re: /(holding tank|adopt(ing|ion|ed)? (a |an |from|someone|member)|orphan(ed)? member|no sponsor|unsponsored|release to tank)/i,
a: 'The holding tank is where free members who joined without a sponsor wait, and anyone can be picked up first come. To adopt you need payouts switched on and your own $20 or larger package bought; then open Members > My line > Holding tank. You can hold 2 open adoptions at a time and each one runs for 7 days, and if that person never links a wallet or buys they drop back into the tank. Adopting sets you as their sponsor, opens a chat and emails them, and their first purchase binds to you on the chain. You can also release one of your own free referrals into the tank for somebody else to work with, though not one you adopted less than 3 days ago. A member can be adopted twice in their lifetime at most, so an adoption you drop still costs them one of those chances. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list: their payouts are on hold until someone adopts them, and after 24 hours the site assigns them to the next eligible adopter in turn (own $20 package, fewer than 2 open adoptions, signed in within the last 7 days). Adopters take turns, so the one assigned least recently goes first.' },
@@ -246,7 +249,7 @@ ${passTiersFact()}${refuelFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagen
- WALLETS + BUYING POL (Training > Wallets and buying POL, /wallets, members only): preferred MetaMask (recommended; extra accounts for Qualified Start), Phantom (PHANTOM GOTCHA: Polygon is OFF by default; Settings > Active Networks > turn on Polygon, otherwise connect/buy fails or shows the wrong network; seen with Jim Watts' EB team 2026-09-13), SafePal, Coinbase Wallet; Trust works but blocks buys spending most of its POL (keep ~2x). MoonPay flow: connect wallet, Buy packages > "Buy POL with a card" opens MoonPay with POL on Polygon + the member's address prefilled; card/Apple Pay/Google Pay; first-time ID check; minimum order ~$30; buy package cost + 2-3 POL for fees; POL arrives in minutes; then buy. Exchanges: withdraw POL on the Polygon network. Never MATIC on Ethereum, never share the recovery phrase.
- INTRO VIDEO ON THE WALL: Profile > social links has an "Intro video" field (YouTube, Vimeo or direct .mp4 link). It embeds on the member's public wall page (/wall/<username>) right under their bio, above the three-level line and the join button.
- HOLDING TANK (Members > My line > Holding tank card): free members who joined with no sponsor wait there; a member who has switched on payouts AND bought their own $20+ package can Adopt one (first come, max 2 open adoptions, 7-day window; if the person never links a wallet or buys, they fall back into the tank; a person can be adopted twice at most). Adopting sets the sponsor, opens a chat and emails the member; their first purchase then binds to the adopter on-chain. Members can also "Release to tank" one of their own free referrals (pay it forward), but NOT someone they adopted less than 3 days ago: an adoption is a commitment, and a dropped adoption still counts toward that person's two-adoption lifetime limit. Releases are posted to the feed and Telegram like pickups. Admin sees the tank under Members.
- TANK ACTIVATION HOLD (2026-10-27, Marty: never default a tank member to the company): a tank member (no sponsor, not activated) can NOT switch on payouts on its own yet (a PURCHASE is NEVER held, Marty 2026-10-27: with no sponsor anywhere a buy goes ahead under the catch position #1); the Wallet tab and Getting started card say "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left, and the activate button is hidden. The 24-hour clock starts when they link a wallet; they then show at the top of every holding tank with a green "Ready to activate" badge and hours left, and a post goes to the team's Telegram payments topic. If nobody adopts them in 24 hours, the site auto-assigns them to the next eligible adopter in rotation (own $20+ package, fewer than 2 open adoptions, signed in within 7 days, not suspended; least recently auto-assigned first); the adopter gets a chat + email and Telegram shows the pickup marked (auto-assigned). If nobody is eligible they stay on hold and the admin is alerted; never the company. Someone whose same email or wallet already has a sponsor on LinkSpin is placed under that sponsor instead (not one they were released or rescued from). A member who arrived through a sponsor link is never held. Once they have a sponsor the hold lifts by itself.
- TANK ACTIVATION HOLD (2026-10-27, Marty: never default a tank member to the company): a tank member (no sponsor, not activated) can NOT switch on payouts on its own yet (a PURCHASE is NEVER held, Marty 2026-10-27: with no sponsor anywhere a buy goes ahead under the catch position #1); the Wallet tab and Getting started card say "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left, and the activate button is hidden. The 24-hour clock starts when they link a wallet; they then show at the top of every holding tank with a green "Ready to activate" badge and hours left, and a post goes to the team's Telegram payments topic. If nobody adopts them in 24 hours, the site auto-assigns them to the next eligible adopter in rotation (own $20+ package, fewer than 2 open adoptions, signed in within 7 days, not suspended; least recently auto-assigned first); the adopter gets a chat + email and Telegram shows the pickup marked (auto-assigned). If nobody is eligible they stay on hold and the admin is alerted; never the company. Someone whose same email or wallet already has a sponsor on LinkSpin is placed under that sponsor instead (not one they were released or rescued from). A member who arrived through a sponsor link is never held. Once they have a sponsor the hold lifts by itself. ONE-TAP SWITCH ON PAYOUTS (2026-10-27): every tank assignment (manual adoption or the 24-hour auto-assign) sends the member a chat and an email with a Switch on payouts link, https://instantadpay.com/my?activate=1#wallet; it opens the Wallet tab and starts the normal Activate payouts flow with the new sponsor prefilled (after sign-in, and after linking a wallet if none is linked yet). It never starts while the hold applies or when no sponsor resolves. The site cannot activate for anyone: activation is one free transaction from the member's own wallet. Not activated 24 hours after the assignment: one reminder email to the member with the same link and one notice to the sponsor ("@x hasn't switched on payouts yet; a nudge from you helps"); at 72 hours one last email to the member only; both stop once the member switches on payouts or buys.
- DAILY CLAIM STREAK: finishing the daily ad set and claiming pays 5 credits on day 1, 7 on day 2, 10 from day 3, and 25 on every 7th consecutive day; miss a day and it restarts. After the set, verified visits (up to 20 a day, 1 credit each) keep earning, and the credits are meant to be spent on a campaign.
- FOUR-MINUTE OVERVIEW VIDEO (2026-09-16): 'InstantAdPay in four minutes' is the first card on Members > Training (group 'Start here') and embedded on the home page at instantadpay.com/#overview-video (hero button 'Watch the 4-minute overview'). Send it to anyone asking what the platform is; the tab-by-tab walkthrough videos on Training go deeper. It is evergreen: no dates, no launch talk.
- ANTI-FRAUD CHECKS (2026-09-16): at sign-up the site records IP, browser type and a browser cookie id. A second account from a browser that already has one is refused, so is a burst of new accounts from one connection in a day, and so is a sign-up through an invite link whose owner used that same browser. A sign-up from the same IP as the sponsor is allowed but flagged (households are fine). Flagged accounts never count on the leaderboard and cannot adopt from the holding tank; a suspended account cannot sign in. If a member says they were refused at sign-up, or asks how to get a second account to qualify themselves: one account per person, sign in to the existing one, and use QUALIFIED START (Buy packages tab) to link extra wallets of their own as positions under that account; each linked wallet that buys $20+ counts as one of their qualifying buyers, credits pool, and half of each such purchase returns to their main wallet. Levels 2 and 3 open at 2 and 5 qualifying buyers whether those buyers are referrals or the member's own linked positions. Shared computer at work or a library: contact support. Never suggest a second account.
+36
View File
@@ -41,6 +41,41 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
if (h && h.until) { const ms = h.until - Date.now(); t += ms > 0 ? ' Time left: ' + holdLeft(ms) + '.' : ' Any minute now.'; }
return t;
}
// one-tap switch on payouts (2026-10-27): the tank assignment chat + emails link to /my?activate=1#wallet. The intent
// survives the sign-in and the wallet link (memory + sessionStorage) and runs the Activate button's own flow once.
const ACT_KEY = 'iap.activateIntent';
let ACT_INTENT = /[?&]activate=1(&|#|$)/.test(location.search);
try { if (ACT_INTENT) sessionStorage.setItem(ACT_KEY, String(Date.now())); else { const t = Number(sessionStorage.getItem(ACT_KEY)) || 0; ACT_INTENT = t > 0 && Date.now() - t < 3600000; } } catch (e) {}
function clearActIntent() {
ACT_INTENT = false; try { sessionStorage.removeItem(ACT_KEY); } catch (e) {}
try { if (/[?&]activate=1/.test(location.search)) { const q = location.search.replace(/([?&])activate=1(&|$)/, (m, a, b) => b ? a : '').replace(/^&/, '?').replace(/[?&]$/, ''); history.replaceState(null, '', location.pathname + q + location.hash); } } catch (e) {}
}
function actNote(text) {
let n = $('actIntentNote');
if (!n && text) { n = document.createElement('p'); n.id = 'actIntentNote'; n.className = 'small'; n.style.cssText = 'margin:8px 0;color:#22c55e;font-weight:600'; }
if (!n) return null;
n.hidden = !text; n.textContent = text || '';
return n;
}
async function runActivateIntent(me) {
if (!ACT_INTENT || runActivateIntent.started || !me || !me.signedIn) return;
if (me.memberId) { clearActIntent(); IAP.status('Your payouts are already switched on.', 'ok'); return; }
// never auto-start while the tank hold applies, a sponsor is blocked, or no real sponsor resolves (it would bind the fallback)
if (TANK_HOLD || me.tankHold || me.sponsorBlocked || !me.sponsorId || me.sponsorFallback || me.sponsorRouted) { clearActIntent(); return; }
const who = me.sponsorName || ('member #' + me.sponsorId);
setPane('wallet');
if (!me.address) { // link the wallet first; render() after the link comes back here and carries on
const n = actNote('Step 1: link your wallet (one free signature). Then switching on payouts with ' + who + ' starts by itself.');
if (n && $('linkBtn') && !n.isConnected) $('linkBtn').insertAdjacentElement('beforebegin', n);
if ($('linkCard')) $('linkCard').scrollIntoView({ behavior: 'smooth', block: 'center' });
return;
}
runActivateIntent.started = true; clearActIntent();
const n = actNote('One free transaction switches on your payouts and locks ' + who + ' in as your sponsor. Confirm it in your wallet.');
if (n && !n.isConnected) $('activateBtn').insertAdjacentElement('beforebegin', n);
$('activateCard').scrollIntoView({ behavior: 'smooth', block: 'center' });
setTimeout(() => { if (!$('activateBtn').hidden && !$('activateBtn').disabled) $('activateBtn').click(); }, 400); // the Activate button's own flow (injected wallet, or the WalletConnect picker on a phone)
}
function nextMove(d) {
if (TANK_HOLD && d.address && !d.memberId) return tankHoldText(TANK_HOLD);
if (!d.address) return 'Grab your link below and start sharing today. Then link your wallet (one free signature) so every payment can lock to you before your people start buying.';
@@ -941,6 +976,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
{ let hn = $('tankHoldNote'); // held for an adopter: say so, and no activate button
if (!hn) { hn = document.createElement('p'); hn.id = 'tankHoldNote'; hn.className = 'small'; hn.style.cssText = 'margin:8px 0 0;color:#22c55e'; $('activateBtn').insertAdjacentElement('beforebegin', hn); }
hn.hidden = !TANK_HOLD; hn.textContent = TANK_HOLD ? tankHoldText(TANK_HOLD) : ''; $('activateBtn').hidden = !!TANK_HOLD; }
runActivateIntent(me).catch(() => {}); // arrived from the one-tap "Switch on payouts" link (tank assignment chat/email)
$('activityArea').hidden = !me.memberId;
$('campGate').hidden = true; // earned credits fund campaigns for everyone
$('campaignCard').hidden = false;
+1 -1
View File
@@ -1223,7 +1223,7 @@
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261016p"></script>
<script src="/assets/support.js?v=20261016a"></script>
<script src="/assets/my.js?v=20261027th"></script>
<script src="/assets/my.js?v=20261027pa"></script>
<script src="/assets/fuel.js?v=20261025ff"></script>
<script src="/assets/engine-room.js?v=20261025ff"></script>
<script src="/assets/chat.js?v=20261016n"></script>
+131 -11
View File
@@ -8,7 +8,8 @@
// reaches LinkSpin): a tank account links a wallet -> /api/me + /api/sponsor answer tankHold with no fallback sponsor,
// the Wallet tab hides Activate payouts and shows the hold text, the Getting started card has no activate button,
// Admin tank shows the ready badge; a member who joined through a link is never held; a LinkSpin row naming a sponsor
// aligns a tank member instead of holding them. Never production. Exit code 1 on any failure.
// aligns a tank member instead of holding them; the one-tap /my?activate=1#wallet link (stubbed wallet) starts the Activate
// flow only with a wallet, a real sponsor and no hold, and carries on after an on-page sign-in. Never production. Exit code 1 on any failure.
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
@@ -42,22 +43,25 @@ function fakeAccounts() {
async sponsorOf(e) { const a = by.get(e); if (!a || !a.sponsorRef) return null; return (await this.byUsername(a.sponsorRef)) || (await this.byCode(a.sponsorRef)); }
};
}
function bench() {
function bench(o) {
o = o || {};
const tankPath = path.join(SITE, 'tank.js'); delete require.cache[require.resolve(tankPath)];
const tank = require(tankPath);
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-tankhold-'));
const accounts = fakeAccounts(); const events = []; const chats = []; const mails = []; const alerts = []; const assigned = []; const net = {};
const dir = o.dir || fs.mkdtempSync(path.join(os.tmpdir(), 'iap-tankhold-'));
const accounts = o.accounts || fakeAccounts(); const events = []; const chats = []; const mails = []; const alerts = []; const assigned = []; const net = {};
const notices = []; const claims = o.claims || new Set(); const onChain = o.onChain || new Set();
const blocked = new Set();
const env = { now: Date.now() };
const env = o.env || { now: Date.now() };
tank.init({ dataDir: dir, accounts, chain: { recentEvents: () => events.slice().reverse(), getConfig: () => ({}) },
messages: { sendChat: async (id, from, to, text) => { chats.push({ from, to, text }); }, lastFrom: async () => 0 },
mailer: { hasKey: () => true, send: async (to, subject) => { mails.push({ to, subject }); } }, site: 'https://iap.test',
mailer: { hasKey: () => true, send: async (to, subject, body) => { mails.push({ to, subject, body }); } }, site: 'https://iap.test',
hooks: { network: e => net[e] || null, isSuspended: () => false, excluded: () => false, payoutBlocked: async id => blocked.has(id), companyId: () => 1,
assigned: r => { assigned.push(r); }, adminAlert: t => { alerts.push(t); } } });
assigned: r => { assigned.push(r); }, adminAlert: t => { alerts.push(t); },
claim: k => { if (claims.has(k)) return false; claims.add(k); return true; }, activated: a => onChain.has(a.address), notify: async (to, subject, text) => { notices.push({ to, subject, text }); } } });
tank.setClock(() => env.now);
let block = 1000;
const buyer = (email, memberId, o) => { const a = accounts.add(email, Object.assign({ memberId, address: '0x' + crypto.randomBytes(20).toString('hex'), lastSeen: env.now - H }, o || {})); events.push({ type: 'Purchase', buyerId: memberId, priceCents: 2000, block: block++ }); return a; };
return { tank, accounts, events, chats, mails, alerts, assigned, net, blocked, env, buyer, dir };
return { tank, accounts, events, chats, mails, alerts, assigned, net, blocked, env, buyer, dir, notices, claims, onChain };
}
async function partA() {
console.log('-- Part A: tank.js with a mocked clock');
@@ -94,6 +98,9 @@ async function partA() {
ok(recs[0] && recs[0].note === 'auto-assigned after 24 hours in the tank' && recs[0].status === 'open', 'adoption record note', recs[0] && recs[0].note);
ok(B.chats.some(c => c.from === 'a@x.co' && c.to === 'free@x.co'), 'sponsor chat opened');
ok(B.mails.some(m => m.to === 'free@x.co') && B.mails.some(m => m.to === 'a@x.co' && /holding tank is now in your line/.test(m.subject)), 'both sides emailed');
const LINK = 'https://iap.test/my?activate=1#wallet';
ok(B.chats.some(c => c.to === 'free@x.co' && c.text.includes('Switch on payouts in one tap') && c.text.includes(LINK)), 'auto-assign chat carries the one-tap link');
ok(B.mails.some(m => m.to === 'free@x.co' && m.body.includes('Switch on payouts: ' + LINK) && m.body.includes('locks @a in as your sponsor')), 'auto-assign member email carries the one-tap link');
ok(B.assigned.length === 1, 'assigned hook fired (Telegram pickup line with "(auto-assigned)")');
// second ready member: rotation moves to B (A was just auto-assigned)
accounts.add('free2@x.co', { address: '0x' + 'c'.repeat(40) });
@@ -124,6 +131,64 @@ async function partA() {
const h5 = await tank.holdFor(f5);
ok(h5 && h5.hold && h5.hold.until <= env.now, 'still held past the clock (client shows "Any minute now")');
}
{ // one-tap link + switch-on-payouts reminders (24 h member + sponsor, 72 h member only), mocked clock
const B = bench(); const { tank, accounts, env } = B; const LINK = 'https://iap.test/my?activate=1#wallet';
B.buyer('sp@x.co', 41);
accounts.add('m1@x.co', { address: '0x' + '7'.repeat(40) }); accounts.add('m2@x.co'); accounts.add('m3@x.co', { address: '0x' + '8'.repeat(40) }); accounts.add('m4@x.co', { address: '0x' + '9'.repeat(40) });
const r = await tank.adopt('sp@x.co', 'm1', 'Hey, I am your new sponsor.');
ok(r && r.ok && !r.auto, 'manual adoption (setup)', JSON.stringify(r && r.error));
const chat = B.chats.find(c => c.to === 'm1@x.co');
ok(chat && chat.text === 'Hey, I am your new sponsor.\n\nSwitch on payouts in one tap (one free transaction, it locks me in as your sponsor): ' + LINK, 'manual adoption chat: own note + the one-tap line', chat && chat.text);
const mail = B.mails.find(m => m.to === 'm1@x.co');
ok(mail && mail.body.includes('Switch on payouts: ' + LINK) && !mail.body.includes('No wallet linked yet'), 'manual adoption email: link, no wallet sentence when linked');
await tank.adopt('sp@x.co', 'm2'); // no wallet yet
ok(B.mails.some(m => m.to === 'm2@x.co' && m.body.includes('No wallet linked yet? The same link shows you how')), 'no wallet: the email says the link walks them through linking');
const t0 = env.now;
env.now = t0 + 23 * H; let p = await tank.payTick();
ok(p.sent.length === 0, 'no reminder before 24 h');
accounts._by.get('m2@x.co').memberId = 51; // m2 switched on payouts: no reminder ever
env.now = t0 + 24 * H + 60000; const mailsBefore = B.mails.length;
p = await tank.payTick();
const r1 = B.mails.slice(mailsBefore);
ok(p.sent.length === 1 && p.sent[0].email === 'm1@x.co' && p.sent[0].stage === 1, '24 h: one reminder, only for the member still off', JSON.stringify(p.sent));
ok(r1.length === 1 && r1[0].to === 'm1@x.co' && r1[0].subject === 'Reminder: switch on payouts with @sp on InstantAdPay' && r1[0].body.includes(LINK), '24 h member email: subject + one-tap link', r1[0] && r1[0].subject);
ok(B.notices.length === 1 && B.notices[0].to === 'sp@x.co' && B.notices[0].subject === "@m1 hasn't switched on payouts yet" && B.notices[0].text.startsWith("@m1 hasn't switched on payouts yet; a nudge from you helps.") && B.notices[0].text.includes(LINK), '24 h sponsor notice', B.notices[0] && B.notices[0].text.slice(0, 80));
ok(!r1.some(m => m.to === 'sp@x.co'), 'the sponsor gets a notice, not an email');
await tank.payTick(); env.now += 15 * 60000; p = await tank.payTick();
ok(p.sent.length === 0 && B.notices.length === 1, 'idempotent: later ticks send nothing more before 72 h');
ok(tank.payView().find(x => x.email === 'm2@x.co').done === 'activated', 'activated member: record closed (activated)');
env.now = t0 + 72 * H + 60000; const m72 = B.mails.length;
p = await tank.payTick();
ok(p.sent.length === 1 && p.sent[0].stage === 2 && B.mails.length === m72 + 1 && B.mails[m72].subject === 'Last reminder: switch on payouts with @sp on InstantAdPay' && B.mails[m72].body.includes(LINK), '72 h: the last reminder, member only', JSON.stringify(p.sent));
ok(B.notices.length === 1, '72 h: no second sponsor notice');
env.now += 24 * H; p = await tank.payTick();
ok(p.sent.length === 0 && tank.payView().find(x => x.email === 'm1@x.co').done === 'reminded', 'after 72 h: done, nothing more');
ok(!/—/.test(B.chats.map(c => c.text).join(' ') + B.mails.map(m => m.subject + m.body).join(' ') + B.notices.map(n => n.subject + n.text).join(' ')), 'no em dashes in member texts');
// m3 activated on chain (MemberActivated) before the account has a memberId; m4 moved away before 24 h: both stop
B.buyer('sp2@x.co', 42);
const r3 = await tank.adopt('sp2@x.co', 'm3'); ok(r3 && r3.ok, 'second sponsor adopts m3 (setup)', JSON.stringify(r3 && r3.error));
const r4 = await tank.adopt('sp2@x.co', 'm4'); ok(r4 && r4.ok, 'second sponsor adopts m4 (setup)', JSON.stringify(r4 && r4.error));
const t3 = env.now; B.onChain.add(accounts._by.get('m3@x.co').address);
accounts._by.get('m4@x.co').sponsorRef = '';
env.now = t3 + 25 * H; p = await tank.payTick();
ok(p.sent.length === 0, 'activated on chain / sponsor changed: no reminder', JSON.stringify(p.sent));
const pv = tank.payView();
ok(pv.find(x => x.email === 'm3@x.co').done === 'activated' && pv.find(x => x.email === 'm4@x.co').done === 'moved', 'records closed as activated / moved');
ok((await tank.adminView()).payReminders.length >= 4, 'adminView lists the reminder records');
}
{ // deploy overlap: a second app copy with a stale tank-ready.json and the shared claim table sends nothing twice
const accounts = fakeAccounts(); const claims = new Set(); const env = { now: Date.now() };
const A = bench({ accounts, claims, env });
A.buyer('ov@x.co', 61); accounts.add('ovm@x.co', { address: '0x' + '6'.repeat(40) });
await A.tank.adopt('ov@x.co', 'ovm');
const stale = fs.readFileSync(path.join(A.dir, 'tank-ready.json'), 'utf8');
env.now += 25 * H;
const pa = await A.tank.payTick();
const dir2 = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-tankhold-ov-')); fs.writeFileSync(path.join(dir2, 'tank-ready.json'), stale);
const Bc = bench({ accounts, claims, env, dir: dir2 }); // copy B: same accounts + claims, stale state
const pb = await Bc.tank.payTick();
ok(pa.sent.length === 1 && pb.sent.length === 0 && Bc.mails.length === 0 && Bc.notices.length === 0, 'overlap: copy A sends the 24 h reminder, stale copy B sends nothing', JSON.stringify({ a: pa.sent.length, b: pb.sent.length }));
}
{ // own-downline adopter skipped
const B = bench(); const { tank, accounts, env } = B;
accounts.add('top@x.co', { address: '0x' + '1'.repeat(40) });
@@ -173,9 +238,10 @@ async function partB() {
const api = async (p, body, hdr) => { const r = await fetch(BASE + p, body ? { method: body.method || 'POST', headers: Object.assign({ 'Content-Type': 'application/json' }, hdr || {}), body: JSON.stringify(body.data || body) } : { headers: hdr || {} }); let j = null; try { j = await r.json(); } catch (e) {} return { status: r.status, j }; };
const adminH = { Authorization: 'Bearer ' + ADMIN };
await api('/api/admin/site', { method: 'PATCH', data: { fraudMaxSignupsPerIpDay: 20 } }, adminH);
async function signIn(email, username, extraCookie) {
const s = await api('/api/auth/email/start', { email, fts: Date.now() - 5000 }, extraCookie ? { Cookie: extraCookie } : null);
const v = await fetch(BASE + '/api/auth/email/verify', { method: 'POST', headers: Object.assign({ 'Content-Type': 'application/json' }, extraCookie ? { Cookie: extraCookie } : {}), body: JSON.stringify({ email, code: s.j && s.j.devCode }) });
async function signIn(email, username, extraCookie, ip) { // ip: X-Forwarded-For of its own (the code guard allows 5 sends per IP per 10 min)
const xf = ip ? { 'X-Forwarded-For': ip } : {};
const s = await api('/api/auth/email/start', { email, fts: Date.now() - 5000 }, Object.assign({}, xf, extraCookie ? { Cookie: extraCookie } : {}));
const v = await fetch(BASE + '/api/auth/email/verify', { method: 'POST', headers: Object.assign({ 'Content-Type': 'application/json' }, xf, extraCookie ? { Cookie: extraCookie } : {}), body: JSON.stringify({ email, code: s.j && s.j.devCode }) });
const cookie = (v.headers.getSetCookie ? v.headers.getSetCookie() : [v.headers.get('set-cookie')]).map(c => String(c).split(';')[0]).filter(c => /^iap\./.test(c) || c.includes('=')).join('; ');
if (username) await api('/api/my/profile', { username }, { Cookie: cookie });
return cookie;
@@ -234,6 +300,60 @@ async function partB() {
ok(/Matching you with a sponsor/.test(st.gs) && !st.gsBtn, 'Getting started: hold text, no activate button', st.gs.slice(0, 120));
await page.screenshot({ path: path.join(SITE, 'qa/out/tank-hold-wallet.png') }).catch(() => {});
ok(!errs.length, 'no page errors', errs.join(' | ').slice(0, 200));
// 5. one-tap link /my?activate=1#wallet (2026-10-27): IAPWallet.activate is stubbed in the page (records the sponsor id,
// never reaches a wallet); it must start only for a signed-in member with a wallet, a real sponsor and no hold
const STUB = () => { window.__act = []; let real; Object.defineProperty(window, 'IAPWallet', { configurable: true, get() { return real; },
set(v) { if (v && v.activate) v.activate = async id => { window.__act.push(id); throw new Error('qa: activation stub'); }; real = v; } });
try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} };
async function actCtx(cookie, ip) { // ip: its own address for the on-page sign-in (the code guard allows 5 sends per IP per 10 min)
const c = await browser.newContext(Object.assign({ viewport: { width: 390, height: 844 } }, ip ? { extraHTTPHeaders: { 'X-Forwarded-For': ip } } : {})); await c.addInitScript(STUB);
if (cookie) await c.addCookies(cookie.split('; ').filter(Boolean).map(x => { const i = x.indexOf('='); return { name: x.slice(0, i), value: x.slice(i + 1), url: BASE }; }));
const pg = await c.newPage(); pg.on('pageerror', e => errs.push(e.message)); return { c, pg };
}
const actState = pg => pg.evaluate(() => { const n = document.getElementById('actIntentNote'); return { act: window.__act, note: n && !n.hidden ? n.textContent : null, url: location.pathname + location.search + location.hash, hold: (document.getElementById('tankHoldNote') || {}).hidden === false }; });
{ // held tank member: never triggers, the param is dropped, the hold text shows
const { c, pg } = await actCtx(tc); await pg.goto(BASE + '/my?activate=1#wallet', { waitUntil: 'load' }); await pg.waitForTimeout(4000);
const s1 = await actState(pg);
ok(s1.act.length === 0 && !s1.note && s1.hold && !/activate=1/.test(s1.url), '?activate=1 on a held tank member: no activation, hold text, param dropped', JSON.stringify(s1));
await c.close();
}
{ // sponsor link to a member who never switched on payouts (walk-up / routed): no real sponsor, never triggers
ok(me2 && me2.sponsorRouted, 'setup: the link-joined member routes past an unactivated sponsor', JSON.stringify(me2 && me2.sponsorRouted));
const { c, pg } = await actCtx(jc); await pg.goto(BASE + '/my?activate=1#wallet', { waitUntil: 'load' }); await pg.waitForTimeout(4000);
const s2 = await actState(pg);
ok(s2.act.length === 0 && !s2.note, '?activate=1 when no real sponsor resolves: no activation', JSON.stringify(s2));
await c.close();
}
// a member with a real sponsor (#21) and a wallet: the Activate flow starts at once with #21
const pc = await signIn('qa-pay@example.com', 'qapayone', 'iap.sponsor=21', '10.78.0.1'); await linkWallet(pc);
const mp = (await api('/api/me', null, { Cookie: pc })).j;
ok(mp && mp.sponsorId === 21 && !mp.sponsorFallback && !mp.tankHold && !mp.memberId, 'setup: sponsored member, sponsor #21 resolves', JSON.stringify({ id: mp && mp.sponsorId, f: mp && mp.sponsorFallback }));
{ const { c, pg } = await actCtx(pc); await pg.goto(BASE + '/my?activate=1#wallet', { waitUntil: 'load' }); await pg.waitForTimeout(4500);
const s3 = await actState(pg);
ok(s3.act.length === 1 && s3.act[0] === 21, '?activate=1: the Activate flow starts once with the sponsor prefilled (#21)', JSON.stringify(s3));
ok(s3.note === 'One free transaction switches on your payouts and locks member #21 in as your sponsor. Confirm it in your wallet.', 'explainer line above the Activate button', s3.note);
ok(/#wallet$/.test(s3.url) && !/activate=1/.test(s3.url), 'Wallet tab open, param consumed', s3.url);
await pg.reload({ waitUntil: 'load' }); await pg.waitForTimeout(3500);
ok((await actState(pg)).act.length === 0, 'a reload does not start it again');
await pg.screenshot({ path: path.join(SITE, 'qa/out/tank-activate-link.png') }).catch(() => {});
await c.close(); }
{ // signed out: sign in on the page, then the same flow carries on
const c2 = await signIn('qa-pay2@example.com', 'qapaytwo', 'iap.sponsor=21', '10.78.0.2'); await linkWallet(c2);
const { c, pg } = await actCtx(null, '10.77.' + (1 + Math.floor(Math.random() * 250)) + '.9'); await pg.goto(BASE + '/my?activate=1#wallet', { waitUntil: 'load' }); await pg.waitForTimeout(4000);
ok((await actState(pg)).act.length === 0, 'signed out: nothing starts before sign-in');
await pg.fill('#mcEmail', 'qa-pay2@example.com'); await pg.click('#mcSendBtn');
await pg.waitForFunction(() => (document.getElementById('mcCode') || {}).value, null, { timeout: 15000 }).catch(() => {});
await pg.click('#mcVerifyBtn'); await pg.waitForTimeout(5000);
const s4 = await actState(pg);
ok(s4.act.length === 1 && s4.act[0] === 21, 'signed out -> sign in -> the Activate flow continues with #21', JSON.stringify(s4));
await c.close(); }
{ // sponsored, no wallet yet: link first (note), nothing starts; the intent waits for the link
const c3 = await signIn('qa-pay3@example.com', 'qapaythree', 'iap.sponsor=21', '10.78.0.3');
const { c, pg } = await actCtx(c3); await pg.goto(BASE + '/my?activate=1#wallet', { waitUntil: 'load' }); await pg.waitForTimeout(4000);
const s5 = await actState(pg);
ok(s5.act.length === 0 && s5.note === 'Step 1: link your wallet (one free signature). Then switching on payouts with member #21 starts by itself.', 'no wallet yet: asks to link first, nothing starts', JSON.stringify(s5));
await c.close(); }
ok(!errs.length, 'no page errors (one-tap link pages)', errs.join(' | ').slice(0, 200));
} finally {
if (browser) await browser.close().catch(() => {});
try { srv.kill(); } catch (e) {}
+9 -5
View File
@@ -638,7 +638,11 @@ async function boot() {
// activation hold + 24-hour safety net (2026-10-27): a tank member is never bound under the fallback position
hooks: { network: (email, address) => lsinbound.networkSponsor(email, address), isSuspended: em => fraud.isSuspended(em), excluded: em => fraud.excluded(em),
payoutBlocked: id => payoutChainBlocked(id, 2), companyId: () => Number(siteConfig().defaultSponsorId) || 1,
assigned: r => { tankPickupPost(r.adopterName, r.adopteeName, true); }, adminAlert: text => tankAdminAlert(text) } });
assigned: r => { tankPickupPost(r.adopterName, r.adopteeName, true); }, adminAlert: text => tankAdminAlert(text),
// switch-on-payouts reminders after an assignment (2026-10-27): one send per key across both app copies (deploy overlap),
// the sponsor's nudge as an in-app notice (never a pop-up broadcast), stop once the wallet is on chain
claim: key => marks.claim(key), activated: a => !!(a && a.address && activationByAddress().get(String(a.address).toLowerCase())),
notify: async (email, subject, text) => { 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', [email], subject, html, 'notice'); } } });
// LinkSpin registry sync (2026-10-08): every account change is pushed to LinkSpin within seconds; a 2-minute reconcile catches the rest
lssync.init({ dataDir: DATA_DIR, accounts, follow: followStore, tank: () => tank }); accounts.onChange(email => lssync.touch(email));
lsinbound.init({ dataDir: DATA_DIR, accounts, lssync, follow, store: followStore });
@@ -1495,7 +1499,7 @@ async function tankAdminAlert(text) {
// who linked a wallet, run the safety net, and tell the shared payments topic once per member who became ready
async function tankReadyTick() {
const r = await tank.readyTick();
if (r.aligned || r.assigned.length || r.held || r.fresh.length) console.log('tank ready tick', JSON.stringify({ fresh: r.fresh.length, aligned: r.aligned, assigned: r.assigned.length, held: r.held }));
if (r.aligned || r.assigned.length || r.held || r.fresh.length || (r.reminders || []).length) console.log('tank ready tick', JSON.stringify({ fresh: r.fresh.length, aligned: r.aligned, assigned: r.assigned.length, held: r.held, payReminders: (r.reminders || []).map(x => x.stage) }));
const sc = siteConfig();
if (!r.fresh.length || !sc.telegramBotToken || !sc.telegramEchoChatId) return r;
const clean = t => String(t || '').replace(/[<>&]/g, '');
@@ -2740,15 +2744,15 @@ const server = http.createServer(async (req, res) => {
if (sponsorId && await payoutChainBlocked(sponsorId, 2)) sponsorId = 0;
const _defSpon = Number(siteConfig().defaultSponsorId) || 1;
// a holding-tank member is never bound under the fallback: held for an adopter (24 h at most, then the rotation)
let tankHold = null;
let tankHold = null, sponsorFallback = false; // sponsorFallback: no real sponsor resolved (the one-tap ?activate=1 flow never auto-starts then)
if (!sponsorId && !memberId && acct && !acct.sponsorRef && !acct.memberId) { try { const h = await tank.holdFor(acct); if (h && h.hold) tankHold = h.hold; } catch (e) { tankHold = { since: null, until: null }; } }
if (tankHold) sponsorBlocked = 'tankHold';
else if (!sponsorId && memberId !== _defSpon) sponsorId = _defSpon; // orphan fallback → #1 (never self-sponsor)
else if (!sponsorId && memberId !== _defSpon) { sponsorId = _defSpon; sponsorFallback = true; } // orphan fallback → #1 (never self-sponsor)
if (memberId && acct && acct.memberId !== memberId) accounts.setMemberId(acct.email, memberId).catch(() => {});
const out = { signedIn: true, gkShop: !!parseCookies(req)['iap.gkshop'], sdShop: !!parseCookies(req)['iap.sdshop'], pwMint: !!parseCookies(req)['iap.pwmint'], returnTo: ['polhunter', 'driprunner', 'passivedrip', 'gemkingdom', 'gkshop', 'spookydoors', 'sdshop', 'pwmint', 'polybreak', 'shardsofvalor'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
address: s.address || (acct && acct.address) || null, memberId,
username: (acct && acct.username) || null,
refCode: (acct && acct.code) || null, sponsorId, tankHold,
refCode: (acct && acct.code) || null, sponsorId, tankHold, sponsorFallback,
// profile + line-banner fields so the Profile pane repopulates on reload (were being saved but not returned)
avatarUrl: (acct && acct.avatarUrl) || null, bio: (acct && acct.bio) || null,
socials: (acct && acct.socials) || null,
+70 -5
View File
@@ -140,11 +140,13 @@ async function adopt(adopterEmail, who, note, opts) {
const text = String(note || '').trim().slice(0, 600) || ('Hi, I am ' + nameOf(me) + '. You joined InstantAdPay without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.');
const ad = await impl().add({ adoptee: target.email, adopter: e, ts: now, expires: now + TTL_MS, status: 'open', note: (opts && opts.recordNote) || text });
{ const rr = RS.load().ready[target.email]; if (rr && !rr.done) { rr.done = now; rr.adoptedBy = e; RS.save(); } } // the hold lifts: their sponsor resolves now
try { await messages.sendChat(me.memberId || 0, e, target.email, text); } catch (err) {}
payTrack(target.email, e, ad.id, auto); // switch-on-payouts reminders at 24 h and 72 h (payTick)
const link = activateLink();
try { await messages.sendChat(me.memberId || 0, e, target.email, text + '\n\n' + chatPayLine(link)); } catch (err) {}
if (mailer && mailer.hasKey()) {
try {
await mailer.send(target.email, nameOf(me) + ' is now your sponsor on InstantAdPay',
'You joined InstantAdPay without a sponsor. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nInstantAdPay');
'You joined InstantAdPay without a sponsor. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + '\n\n' + mailPayBlock(nameOf(me), link, !!target.wallet) + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nInstantAdPay');
} catch (err) {}
if (auto) {
try {
@@ -476,15 +478,78 @@ async function readyTick() {
}
RS.save();
const auto = await autoAssign();
return { fresh, aligned, assigned: auto.assigned, held: auto.held };
const pay = await payTick().catch(e => { console.error('tank payTick', e.message); return { sent: [] }; });
return { fresh, aligned, assigned: auto.assigned, held: auto.held, reminders: pay.sent };
}
// ── one-tap switch on payouts after an assignment (Marty, 2026-10-27) ──
// The contract only has activate(sponsorId) from the member's OWN wallet (non-custodial), so the site cannot switch
// payouts on for them. What it can do: every assignment (manual adoption or the 24-hour safety net) carries a link to
// /my?activate=1#wallet, which starts the Activate flow with the sponsor filled in (my.js), and a member who has not
// switched on payouts gets ONE reminder email at 24 hours (and the new sponsor ONE notice), and a last email at 72 hours.
// Stops as soon as they activate or buy (memberId / MemberActivated), or the sponsor changes. State: tank-ready.json
// `pay` (adoptee email -> { at, adopter, adoptionId, auto, r1, r2, done }). Deploy overlap: each send is gated by
// hooks.claim (marks.claim, one MySQL row per key across both app copies) and the record is saved before the send.
const PAY_R1_MS = 24 * 3600 * 1000; // first reminder (member email + sponsor notice)
const PAY_R2_MS = 72 * 3600 * 1000; // last reminder (member email only)
const activateLink = () => siteUrl + '/my?activate=1#wallet';
const chatPayLine = link => 'Switch on payouts in one tap (one free transaction, it locks me in as your sponsor): ' + link;
function mailPayBlock(sponsorName, link, hasWallet) {
return 'Switch on payouts: ' + link + '\n'
+ 'One tap opens your wallet with ' + sponsorName + ' already filled in as your sponsor. It is one free transaction, no package needed, and it locks ' + sponsorName + ' in as your sponsor so every payment in your line can reach you.'
+ (hasWallet ? '' : ' No wallet linked yet? The same link shows you how (one free signature) and then carries on.');
}
function payTrack(adoptee, adopter, adoptionId, auto) {
const st = RS.load(); st.pay = st.pay || {};
st.pay[String(adoptee).toLowerCase()] = { at: clock(), adopter: String(adopter).toLowerCase(), adoptionId: adoptionId || null, auto: !!auto, r1: 0, r2: 0, done: null };
RS.save();
}
const claimOnce = async key => { if (!hooks.claim) return true; try { return !!(await hooks.claim(key)); } catch (e) { return false; } };
async function payTick() {
const st = RS.load(); st.pay = st.pay || {}; const now = clock(); const sent = [];
for (const [e, rec] of Object.entries(st.pay)) {
if (rec.done) continue;
const a = await accounts.byEmail(e);
if (!a) { rec.done = 'gone'; rec.doneAt = now; continue; }
if (Number(a.memberId) > 0) { rec.done = 'activated'; rec.doneAt = now; continue; } // switched on payouts or bought
if (a.address && hooks.activated) { let act = null; try { act = await hooks.activated(a); } catch (err) {} if (act) { rec.done = 'activated'; rec.doneAt = now; continue; } }
const sp = await accounts.byEmail(rec.adopter);
const toks = sp ? [sp.code, sp.username, sp.memberId ? String(sp.memberId) : null].filter(Boolean).map(x => String(x).toLowerCase()) : [];
if (!sp || !toks.includes(String(a.sponsorRef || '').toLowerCase())) { rec.done = 'moved'; rec.doneAt = now; continue; } // released, expired or moved
const age = now - rec.at; const link = activateLink(); const spName = nameOf(sp); const name = nameOf(a);
const noWallet = a.address ? '' : '\n\nNo wallet linked yet? The same link shows you how (one free signature) and then carries on.';
if (!rec.r1 && age >= PAY_R1_MS) {
rec.r1 = now; RS.save();
if (age >= PAY_R2_MS) rec.r1skipped = true; // already past 72 h (e.g. the app was down): one email only, the last one below
else if (await claimOnce('tankpay1:' + e + ':' + rec.at)) {
if (mailer && mailer.hasKey()) { try { await mailer.send(e, 'Reminder: switch on payouts with ' + spName + ' on InstantAdPay',
'Yesterday ' + spName + ' became your sponsor on InstantAdPay, but your payouts are not switched on yet, so nothing in your line can pay you.\n\nSwitch on payouts: ' + link + '\n\nOne tap opens your wallet with ' + spName + ' already filled in as your sponsor. It is one free transaction, no package needed, and it locks ' + spName + ' in as your sponsor.' + noWallet + '\n\nQuestions? Message ' + spName + ' in your member area: ' + siteUrl + '/my#messages\n\nInstantAdPay'); } catch (err) {} }
if (hooks.notify) { try { await hooks.notify(sp.email, name + ' hasn\'t switched on payouts yet',
name + ' hasn\'t switched on payouts yet; a nudge from you helps. They were assigned to you 24 hours ago and we sent them a reminder with a one-tap link.\n\nSend them a chat from My line (' + siteUrl + '/my#line), or pass on the same link: ' + link + '\n\nWhen they tap it, their wallet opens with you filled in as their sponsor.'); } catch (err) {} }
sent.push({ email: e, stage: 1, adopter: sp.email });
}
}
if (!rec.r2 && age >= PAY_R2_MS) {
rec.r2 = now; RS.save();
if (await claimOnce('tankpay2:' + e + ':' + rec.at)) {
if (mailer && mailer.hasKey()) { try { await mailer.send(e, 'Last reminder: switch on payouts with ' + spName + ' on InstantAdPay',
'Three days ago ' + spName + ' became your sponsor on InstantAdPay, and your payouts are still switched off, so any payment meant for you in your line cannot reach you.\n\nSwitch on payouts: ' + link + '\n\nOne tap opens your wallet with ' + spName + ' already filled in. It is one free transaction, no package needed, and it locks ' + spName + ' in as your sponsor.' + noWallet + '\n\nThis is the last reminder. Your account and your sponsor stay as they are.\n\nInstantAdPay'); } catch (err) {} }
sent.push({ email: e, stage: 2, adopter: sp.email });
}
rec.done = 'reminded'; rec.doneAt = now;
}
}
RS.save();
return { sent };
}
function payView() { return Object.entries(RS.load().pay || {}).map(([email, r]) => Object.assign({ email }, r)).sort((x, y) => y.at - x.at).slice(0, 100); }
function alignedRecent(n) { return RS.load().aligned.slice(-(n || 50)).reverse(); }
async function adminView() {
const recent = await impl().recent(200);
const names = {};
for (const ad of recent) for (const em of [ad.adoptee, ad.adopter]) if (!(em in names)) { const a = await accounts.byEmail(em); names[em] = a ? nameOf(a) : em; }
return { waiting: await waiting(), adoptions: recent.map(ad => Object.assign({}, ad, { adopteeName: names[ad.adoptee], adopterName: names[ad.adopter] })), cap: CAP_OPEN, ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, aligned: alignedRecent(30) };
return { waiting: await waiting(), adoptions: recent.map(ad => Object.assign({}, ad, { adopteeName: names[ad.adoptee], adopterName: names[ad.adopter] })), cap: CAP_OPEN, ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, aligned: alignedRecent(30), payReminders: payView() };
}
module.exports = { init, view, adopt, holdFor, markReady, readyRec, readyTick, autoAssign, alignToNetwork, alignedRecent, setClock, eligibility, READY_MS, release, sweep, rescueSweep, rescueInfo, markContacted, adminView, waiting, hasOwnBuy, recordGift, onFollow, summaryMap, summaryFor, historyMap, CAP_OPEN, TTL_MS, WARN_DAYS, RESCUE_DAYS, MAX_ADOPTIONS };
module.exports = { init, view, adopt, holdFor, markReady, readyRec, readyTick, autoAssign, payTick, payView, activateLink, PAY_R1_MS, PAY_R2_MS, alignToNetwork, alignedRecent, setClock, eligibility, READY_MS, release, sweep, rescueSweep, rescueInfo, markContacted, adminView, waiting, hasOwnBuy, recordGift, onFollow, summaryMap, summaryFor, historyMap, CAP_OPEN, TTL_MS, WARN_DAYS, RESCUE_DAYS, MAX_ADOPTIONS };