Held purchase: nudge the sponsor automatically (email + on-site) to link a wallet and switch on payouts, once an hour at most
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -547,6 +547,30 @@ function sponsorBlockedAlert(who, r) {
|
||||
const sc = siteConfig();
|
||||
if (sc.telegramBotToken && sc.telegramAdminChatId) telegramSend(sc.telegramAdminChatId, text).catch(() => {});
|
||||
else if (ADMIN_EMAIL && mailer.hasKey()) mailer.send(ADMIN_EMAIL, 'InstantAdPay: purchase held, sponsor unresolved', text).catch(() => {});
|
||||
// and the sponsor themselves (Marty, 2026-09-15): a buy is waiting on them, once an hour at most
|
||||
if (r.reason === 'notActivated') sponsorHoldNudge(String(r.tok || ''), k).catch(() => {});
|
||||
}
|
||||
const sponsorNudgeLast = new Map(); // sponsor email -> ts
|
||||
async function sponsorHoldNudge(tok, buyerEmail) {
|
||||
const t = String(tok || '').trim().toLowerCase(); if (!t) return;
|
||||
let sp = await accounts.byCode(t); if (!sp) sp = await accounts.byUsername(t);
|
||||
if (!sp || !sp.email) return;
|
||||
if (Date.now() - (sponsorNudgeLast.get(sp.email) || 0) < 3600000) return; sponsorNudgeLast.set(sp.email, Date.now());
|
||||
const buyer = await accounts.byEmail(buyerEmail); const bn = buyer && buyer.username ? '@' + buyer.username : 'One of your referrals';
|
||||
const step = !sp.address ? 'link a wallet and switch on payouts' : 'switch on payouts';
|
||||
const subject = bn + ' is trying to buy. ' + (sp.address ? 'Switch on payouts' : 'Link your wallet') + ' so it pays you';
|
||||
const lines = [
|
||||
bn + ' just tried to buy an ad package on InstantAdPay, and the purchase is on hold because payouts are not switched on for your account yet. The contract pays your share in the same transaction, but only to a wallet that is switched on, so the site paused the buy instead of sending your 50 percent to someone else.',
|
||||
'To fix it: open the Wallet tab and ' + step + '. One free signature to link, one small transaction to switch on. Takes two minutes, and every purchase in your line from then on pays you the moment it happens.',
|
||||
'Until then their purchase waits, and they have been told why.',
|
||||
'Wallet tab: https://instantadpay.com/my#wallet'
|
||||
];
|
||||
const text = lines.join('\n\n');
|
||||
if (mailer.hasKey()) mailer.send(sp.email, subject, text + '\n\nInstantAdPay').catch(() => {});
|
||||
try {
|
||||
const html = lines.map(l => '<p>' + l.replace(/&/g, '&').replace(/</g, '<').replace(/(https:\/\/[^\s]+)/g, '<a href="$1" target="_blank" rel="noopener">$1</a>') + '</p>').join('');
|
||||
await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [sp.email], subject, html);
|
||||
} catch (e) {}
|
||||
}
|
||||
// The moment someone joins through a code, nudge its owner to activate.
|
||||
// Email a member's sponsor the moment they get a new referral (free OR paid).
|
||||
|
||||
Reference in New Issue
Block a user