Engine Room panel on the LinkSpin Ads screen (Fuel Your Offers stage 4, Marty approved 2026-10-24): engine.js + engine-room.js are the same files as InstantAdPay's. LinkSpin's facts (credits, campaigns, clicks this week and last via coach.clicksSince, free login slots, conversion-pixel goals this month from the Central 1st via convtrack.countSince, conversions in 30 days, and the Banner Spin / spin link / page / testing part states from bannerspin, rotator and pages) are combined with InstantAdPay's facts and the streak from signed /api/partner/engine on InstantAdPay (cached a minute; when it does not answer the panel says so). LinkSpin answers /api/partner/engine for InstantAdPay's tab. /api/my/engine, /api/my/engine/goal (forwarded to InstantAdPay, where the goal lives with the streak). Hidden while refuelStreak is off; greyed "Refuel to start your engine" until the first counted refuel. Chatbot CANNED + FACTS cover it. qa/refuel-engine.test.cjs checks the shared files have not drifted from InstantAdPay's and runs its engine test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,6 +68,7 @@ const marks = require('./marks'); // one-time claims shared by both app copies d
|
||||
const refill = require('./refill');
|
||||
const refuel = require('./refuel');
|
||||
const kit = require('./kit');
|
||||
const engine = require('./engine'); // the Engine Room (same file as InstantAdPay), 2026-10-24
|
||||
const kitspin = require('./kitspin'); // Refuel Kit -> Banner Spin loader // the Refuel Kit: monthly members-only LinkSpin banner sets, personalized per member (2026-10-24) // 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)
|
||||
@@ -749,6 +750,14 @@ async function boot() {
|
||||
}
|
||||
}
|
||||
|
||||
// InstantAdPay's Engine Room facts + the streak for one member (signed /api/partner/engine), cached a minute
|
||||
const iapEngineCache = new Map();
|
||||
async function engineFromIap(email, fresh) {
|
||||
const hit = iapEngineCache.get(email); if (!fresh && hit && Date.now() - hit.at < 60000) return hit.v;
|
||||
let v = null; try { const r = await SF.peerPost(IAP_BASE(), '/api/partner/engine', { email }, 6000); v = r && r.refuel ? { refuel: r.refuel, facts: r.facts } : null; } catch (e) { v = null; }
|
||||
iapEngineCache.set(email, { at: Date.now(), v }); if (iapEngineCache.size > 2000) iapEngineCache.delete(iapEngineCache.keys().next().value);
|
||||
return v;
|
||||
}
|
||||
function siteConfig() {
|
||||
let saved = {};
|
||||
try { saved = JSON.parse(fs.readFileSync(SITE_FILE, 'utf8')); } catch (e) {}
|
||||
@@ -2748,6 +2757,12 @@ const server = http.createServer(async (req, res) => {
|
||||
const sg = await readPartnerSigned(req, 2e6); if (!sg.body) return json(res, sg.status, { error: sg.error });
|
||||
return json(res, 200, { ok: true, n: convtrack.importClicks(sg.body.clicks) });
|
||||
}
|
||||
// -- the Engine Room, partner side: LinkSpin's facts for one member (InstantAdPay builds its panel from them)
|
||||
if (p === '/api/partner/engine' && req.method === 'POST') {
|
||||
const sg = await readPartnerSigned(req, 64000); if (!sg.body) return json(res, sg.status, { error: sg.error });
|
||||
const email = String(sg.body.email || '').trim().toLowerCase(); if (!email) return json(res, 400, { error: 'Which member?' });
|
||||
return json(res, 200, { ok: true, facts: await engine.facts({ site: 'linkspin', adminMember, ads, coach, bannerspin, rotator, pages, convtrack }, email) });
|
||||
}
|
||||
if (p === '/api/partner/conv' && req.method === 'POST') {
|
||||
const sg = await readPartnerSigned(req, 64000); if (!sg.body) return json(res, sg.status, { error: sg.error });
|
||||
const b = sg.body; const email = String(b.email || '').trim().toLowerCase();
|
||||
@@ -3876,6 +3891,20 @@ const server = http.createServer(async (req, res) => {
|
||||
const r = await kitspin.load({ kit, bannerspin, content, uploadsDir: UPLOADS_DIR, email: s.email, month: String(b.month || ''), variant: b.variant, sizes: b.sizes });
|
||||
return json(res, r.error ? (r.status || 400) : 200, r);
|
||||
}
|
||||
// -- the Engine Room panel (2026-10-24): LinkSpin's facts + InstantAdPay's facts and the streak (signed, cached a minute)
|
||||
if (p === '/api/my/engine' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
if (!refuel.cfg().on) return json(res, 200, { on: false });
|
||||
const [own, peer] = await Promise.all([engine.facts({ site: 'linkspin', adminMember, ads, coach, bannerspin, rotator, pages, convtrack }, s.email), engineFromIap(s.email, u.searchParams.get('fresh') === '1')]);
|
||||
if (!peer || !peer.refuel) return json(res, 200, { on: true, error: 'InstantAdPay did not answer just now. Try again in a minute.' });
|
||||
return json(res, 200, engine.build({ refuel: peer.refuel, iap: peer.facts, ls: own, goal: peer.refuel.goal }));
|
||||
}
|
||||
if (p === '/api/my/engine/goal' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const b = await readBody(req);
|
||||
try { const r = await SF.peerPost(IAP_BASE(), '/api/partner/refuel/goal', { email: s.email, goal: b.goal }, 8000); iapEngineCache.delete(s.email); return json(res, 200, r); }
|
||||
catch (e) { return json(res, 502, { error: 'InstantAdPay did not answer just now. Try again in a minute.' }); }
|
||||
}
|
||||
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.' });
|
||||
|
||||
Reference in New Issue
Block a user