Wallet-link nudges: hourly job asks each game (signed with the shared secret) for players with POL waiting and no wallet, sends up to three notices per person (now, 3 days, 10 days) in-app and by opt-in email, stops when a wallet is linked; coach directs badge "POL waiting, no wallet"; admin view and run endpoint

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-07 10:35:16 -05:00
parent ca065e456e
commit 616bd37142
6 changed files with 111 additions and 3 deletions
+8 -1
View File
@@ -25,7 +25,8 @@ let QR = null; try { QR = require('qrcode'); } catch (e) { /* optional */ }
const chatbot = require('./chatbot');
const fraud = require('./fraud');
const coach = require('./coach'); // coaching view, nudges, digest, prospects, link stats
const tank = require('./tank'); // holding tank: unsponsored free members, adoptions, pay-it-forward
const tank = require('./tank');
const walletnudge = require('./walletnudge'); // players with POL waiting in the games and no wallet (2026-10-07) // holding tank: unsponsored free members, adoptions, pay-it-forward
const legacy = require('./legacy'); // Faucet Wave / Tier One Ads bridge: welcome-back credits for listed emails
const traffic = require('./traffic'); // public page views by referring domain (admin Traffic tab)
const promos = require('./promos');
@@ -527,6 +528,10 @@ async function boot() {
setInterval(() => wednesday.tick().catch(e => console.error('wednesday', e.message)), 5 * 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' });
walletnudge.init({ dataDir: DATA_DIR, accounts, mailer, optedIn: updates.optedIn, site: 'https://instantadpay.com',
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [to], subject, html, 'notice'); } });
setTimeout(() => walletnudge.tick().catch(e => console.error('walletnudge', e.message)), 3 * 60 * 1000); // past the deploy overlap window
setInterval(() => walletnudge.tick().catch(e => console.error('walletnudge', e.message)), 60 * 60 * 1000);
await fraud.init({ dataDir: DATA_DIR });
{ // a suspended account is signed out everywhere: every member route sees no session
const realFrom = auth.fromRequest.bind(auth);
@@ -2674,6 +2679,8 @@ const server = http.createServer(async (req, res) => {
const r = await tank.recordGift(s.email, b.email, b.tx, b.pol);
return json(res, r.error ? 400 : 200, r);
}
if (p === '/api/admin/walletnudge' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, walletnudge.adminView()); }
if (p === '/api/admin/walletnudge/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await walletnudge.tick()); }
if (p === '/api/admin/tank' && req.method === 'GET') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
return json(res, 200, await tank.adminView());