Monthly Refuel streak, LinkSpin side (Fuel Your Offers stage 2, Marty approved 2026-10-24). The streak lives on InstantAdPay (one per member across both sites); refuel.js here reports each $25+ LinkSpin package (refuelMinLsCents) once per tx (claim rfev:<tx>, then a pending file in DATA_DIR/refuel-pending retried every minute until InstantAdPay answers), applies LinkSpin's grants and reminders from InstantAdPay's outbox (claim rfg:<ref> before applying, so two app copies or a lost ack never double-grant; grants are purchased-grade addEarned + a credit-log line + a notice), and relays the member's status for the Monthly Refuel panel on Credits and Ads (fuel.js) and the refill notice streak line. Linked positions count for their owner. Chatbot CANNED + FACTS follow the switch, KNOWLEDGE_DATE 2026-10-24. Admin /api/admin/refuel (+ /tick), member /api/my/refuel. MASTER SWITCH refuelStreak default '0': nothing reported, pulled or shown. qa/refuel.test.cjs 10 checks against InstantAdPay's real refuel.js in-process (both switches, cross-site both-engine top-up in both orders, two LinkSpin copies, InstantAdPay down, lost ack, reminders, status).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,7 +65,8 @@ const health = require('./health'); // destination health checks + auto-pause (2
|
||||
const postbacks = require('./postbacks'); // outbound + inbound conversion postbacks on rotator clicks (2026-09-29)
|
||||
const convtrack = require('./convtrack'); // conversion pixel: goals, ad click ids, landing tag + goal pixel, per-goal reports (2026-10-23)
|
||||
const marks = require('./marks'); // one-time claims shared by both app copies during a deploy (event_marks or exclusive files), 2026-10-24
|
||||
const refill = require('./refill'); // refill notices: low / out / idle, one message per owner, conversions tracked (2026-10-24)
|
||||
const refill = require('./refill');
|
||||
const refuel = require('./refuel'); // Monthly Refuel streak, LinkSpin side: reports $25+ packages to InstantAdPay (the source of truth), applies its grants (2026-10-24) // refill notices: low / out / idle, one message per owner, conversions tracked (2026-10-24)
|
||||
const bannerspin = require('./bannerspin'); // Banner Spin: one image URL + one click URL rotating up to 25 banners (2026-10-18)
|
||||
const sources = require('./sources'); // traffic sources: network macros, campaign URLs, per-source postbacks, Reports dimension (2026-10-12)
|
||||
const pages = require('./pages'); // member pages: bridge / review / squeeze, served at /p/<slug> (2026-09-29)
|
||||
@@ -605,7 +606,8 @@ async function boot() {
|
||||
marks.ensureTable().catch(e => console.error('marks table', e.message));
|
||||
setInterval(() => marks.prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
||||
chain.init({ onEvent: ev => { attachNames([ev]).then(a => pushFeed(a[0])).catch(() => pushFeed(ev)); emailOnEvent(ev).catch(() => {}); telegramOnEvent(ev).catch(() => {});
|
||||
if (ev && ev.type === 'Purchase' && ev.buyerId) accounts.byMemberId(Number(ev.buyerId)).then(a => { if (a) return postbacks.convertFor(a.email, 'purchase', { payout: (Number(ev.priceCents) || 0) / 100, currency: 'USD', txid: ev.tx || '' }); }).catch(() => {}); } });
|
||||
if (ev && ev.type === 'Purchase' && ev.buyerId) accounts.byMemberId(Number(ev.buyerId)).then(a => { if (a) return postbacks.convertFor(a.email, 'purchase', { payout: (Number(ev.priceCents) || 0) / 100, currency: 'USD', txid: ev.tx || '' }); }).catch(() => {});
|
||||
if (ev && ev.type === 'Purchase') refuel.onPurchase(ev).catch(e => console.error('refuel report', e.message)); } }); // no-op while refuelStreak is off
|
||||
auth.init({ dataDir: DATA_DIR, chain, isProd: IS_PROD, site: SITE_HOST });
|
||||
accounts.init({ dataDir: DATA_DIR });
|
||||
ads.init({ dataDir: DATA_DIR, chain });
|
||||
@@ -614,7 +616,7 @@ async function boot() {
|
||||
messages.reclassifyCarryNotices(ADMIN_EMAIL || 'house@linkspin.co').then(n => { if (n) console.log('messages: ' + n + ' carry notices made quiet (notice kind)'); }).catch(() => {});
|
||||
reports.init({ dataDir: DATA_DIR });
|
||||
drip.init({ dataDir: DATA_DIR, mailer, accounts, chain, site: SITE_URL });
|
||||
chatbot.init({ dataDir: DATA_DIR, chain });
|
||||
chatbot.init({ dataDir: DATA_DIR, chain, refuelOn: () => refuel.cfg().on });
|
||||
setTimeout(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 1000);
|
||||
setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000);
|
||||
setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends
|
||||
@@ -631,7 +633,11 @@ async function boot() {
|
||||
});
|
||||
// campaign refill notices (2026-10-24, copied from InstantAdPay): told when an ad is nearly out, when it stops, and once more
|
||||
// a week later if credits sit idle; one email + one on-site notice per owner, every send watched for what they did next
|
||||
refill.init({ dataDir: DATA_DIR, siteConfig, ads, accounts, chain, mailer, drip, marks, siteUrl: SITE_URL, houseOwner: ads.HOUSE_OWNER,
|
||||
refuel.init({ dataDir: DATA_DIR, siteConfig, ads, accounts, marks, mailer, drip, siteUrl: SITE_URL, iapBase: IAP_BASE,
|
||||
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [to], subject, html, 'notice'); } });
|
||||
setTimeout(() => refuel.tick().catch(e => console.error('refuel', e.message)), 75000);
|
||||
setInterval(() => refuel.tick().catch(e => console.error('refuel', e.message)), 60 * 1000);
|
||||
refill.init({ dataDir: DATA_DIR, siteConfig, ads, accounts, chain, mailer, drip, marks, siteUrl: SITE_URL, houseOwner: ads.HOUSE_OWNER, streakLine: email => refuel.streakLine(email),
|
||||
creditsFor: async email => { const v = await adminMember.view(email); return (v && v.credits && v.credits.available) || 0; },
|
||||
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@' + SITE_HOST, [to], subject, html, 'notice'); } });
|
||||
setTimeout(() => refill.tick().catch(e => console.error('refill', e.message)), 90000);
|
||||
@@ -766,7 +772,8 @@ function siteConfig() {
|
||||
geoTier1: '', // comma-separated ISO country codes; empty = built-in default (US, CA, GB, AU, NZ, IE, DE, FR, NL, SE, NO, DK, FI, CH, AT, BE)
|
||||
geoTier2: '', // empty = built-in default (rest of Western/Central Europe, JP, KR, SG, HK, TW, IL, Gulf, ZA, BR, MX, AR, CL, CO ...); tier 3 = everything else
|
||||
pnlFixedMonthlyUsd: 0,
|
||||
refillNotices: '1', refillLowPct: 80, // refill notices (2026-10-24): '0' turns them off; the share of a budget delivered that counts as running low
|
||||
refillNotices: '1', refillLowPct: 80,
|
||||
refuelStreak: '0', refuelMinLsCents: 2500, // Monthly Refuel streak (2026-10-24): '0' = nothing reported or shown; the streak itself lives on InstantAdPay // refill notices (2026-10-24): '0' turns them off; the share of a budget delivered that counts as running low
|
||||
campaignEditFee: 100 // credits per ad edit after each campaign's first, free one (Orlando's ask, 2026-10-18); 0 = edits always free
|
||||
}, saved);
|
||||
}
|
||||
@@ -3816,6 +3823,19 @@ const server = http.createServer(async (req, res) => {
|
||||
passedUp: { count: passed.length, unqualified: passed.filter(e => e.reason === 'unqualified').length, sendFailed: passed.filter(e => e.reason === 'send-failed').length },
|
||||
wallets, balances, fixedMonthlyUsd: Number(siteConfig().pnlFixedMonthlyUsd) || 0, burner: burner.status() });
|
||||
}
|
||||
if (p === '/api/admin/refuel' && req.method === 'GET') { // Monthly Refuel, LinkSpin side: switch, link to InstantAdPay, reports waiting to go
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
return json(res, 200, refuel.adminView());
|
||||
}
|
||||
if (p === '/api/admin/refuel/tick' && req.method === 'POST') {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
return json(res, 200, await refuel.tick());
|
||||
}
|
||||
if (p === '/api/my/refuel' && req.method === 'GET') { // the member's Refuel card, from InstantAdPay's record ({ on:false } while switched off)
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
return json(res, 200, await refuel.status(s.email));
|
||||
}
|
||||
if (p === '/api/admin/refill' && req.method === 'GET') { // who was told their ads ran low or out, and what they did next
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
return json(res, 200, refill.stats());
|
||||
|
||||
Reference in New Issue
Block a user