Control Room: shared shell with in-shell sign-in, Reports, Team and Wallet screens; postback rails (click ids, macros, lsid attribution, conversions, outbound + inbound postbacks with SSRF guards)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,8 @@ const leaderboard = require('./leaderboard');
|
||||
const toolkit = require('./toolkit');
|
||||
const registry = require('./registry'); // network registry: who is who across properties (LinkSpin, 2026-09-15)
|
||||
const carry = require('./carry'); // sponsor carry-over: engine activation, claim window, notices
|
||||
const rotator = require('./rotator'); // the rotator: rotations, weighted destinations, /r/<code>
|
||||
const rotator = require('./rotator');
|
||||
const postbacks = require('./postbacks'); // outbound + inbound conversion postbacks on rotator clicks (2026-09-29) // the rotator: rotations, weighted destinations, /r/<code>
|
||||
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
|
||||
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
||||
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
||||
@@ -367,7 +368,8 @@ async function frameCheck(url) {
|
||||
}
|
||||
async function boot() {
|
||||
await db.init({ dataDir: DATA_DIR }); // no-op without DATABASE_URL (JSON mode)
|
||||
chain.init({ onEvent: ev => { attachNames([ev]).then(a => pushFeed(a[0])).catch(() => pushFeed(ev)); emailOnEvent(ev).catch(() => {}); telegramOnEvent(ev).catch(() => {}); } });
|
||||
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(() => {}); } });
|
||||
auth.init({ dataDir: DATA_DIR, chain, isProd: IS_PROD, site: 'linkspin-test.saasy.top' });
|
||||
accounts.init({ dataDir: DATA_DIR });
|
||||
ads.init({ dataDir: DATA_DIR, chain });
|
||||
@@ -384,7 +386,9 @@ async function boot() {
|
||||
pipeline.init({ dataDir: DATA_DIR, accounts, coach, chain });
|
||||
registry.init({ dataDir: DATA_DIR });
|
||||
carry.init({ dataDir: DATA_DIR, accounts, registry, chain, mailer, messages, siteConfig, adminEmail: ADMIN_EMAIL, host: SITE_HOST });
|
||||
rotator.init({ dataDir: DATA_DIR, geo });
|
||||
const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean));
|
||||
rotator.init({ dataDir: DATA_DIR, geo, ownHosts });
|
||||
postbacks.init({ dataDir: DATA_DIR, ownHosts, rotator });
|
||||
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, send: async (c, t, th) => { await telegramSend(c, t, th); return true; } });
|
||||
setInterval(() => snapshot.tick().catch(e => console.error('snapshot', e.message)), 10 * 60 * 1000);
|
||||
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, site: 'https://linkspin-test.saasy.top' });
|
||||
@@ -899,6 +903,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const cookieTail = `; Path=/; SameSite=Lax; Max-Age=${30 * 24 * 3600}${IS_PROD ? '; Secure' : ''}`; // 30 days: whoever brings them back gets the credit
|
||||
const set = [];
|
||||
set.push('iap.sponsor=' + tok + cookieTail); // last touch wins
|
||||
{ const lsid = String(u.searchParams.get('lsid') || ''); if (/^[a-z0-9]{6,20}$/i.test(lsid)) set.push('ls.click=' + lsid + cookieTail); } // the rotator click that brought them (postback attribution)
|
||||
const promo = promos.norm(u.searchParams.get('promo')); if (promo) set.push('iap.promo=' + promo + cookieTail); // partner code, redeemed at signup
|
||||
if (ang) set.push('iap.angle=' + angle + cookieTail);
|
||||
if (!cookies['iap.ref']) set.push('iap.ref=' + encodeURIComponent(coach.refHost(req.headers.referer)) + cookieTail); // first-touch source
|
||||
@@ -1061,6 +1066,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const ref = parseCookies(req)['iap.sponsor'] || ''; // last-touch attribution, locked at account creation
|
||||
const r = await accounts.signup(b.email, b.password, ref);
|
||||
if (r.error) return json(res, 400, r);
|
||||
{ const lc = parseCookies(req)['ls.click']; if (lc) { postbacks.bindClick(String(b.email || '').trim().toLowerCase(), lc); postbacks.convertFor(String(b.email || '').trim().toLowerCase(), 'join', {}).catch(() => {}); } }
|
||||
// sponsor is notified once the new member picks a username (onboarding),
|
||||
// so the email can name them — see /api/my/profile
|
||||
if (b.newsletter) sendy.subscribe(r.account.email, r.account.username || '').catch(() => {}); // pre-checked opt-in, silent
|
||||
@@ -1116,6 +1122,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const r = await accounts.ensure(e, ref, via, joinedRef); // first touch wins; existing accounts unchanged
|
||||
if (r.error) return json(res, 400, r);
|
||||
if (r.created) carry.onJoin(r.account, !!ref).catch(() => {}); // network sponsor carries over when no link was used (LinkSpin)
|
||||
if (r.created) { const lc = parseCookies(req)['ls.click']; if (lc) { postbacks.bindClick(e, lc); postbacks.convertFor(e, 'join', {}).catch(() => {}); } }
|
||||
// the lead is in the door: queue the getting-started sequence (opt-in box is pre-checked on both forms)
|
||||
if (r.created && (b.followups || b.newsletter)) drip.enqueue(e, ref, via).catch(() => {});
|
||||
// a wallet-only session (signed with a wallet, no account) finishing setup:
|
||||
@@ -1185,6 +1192,7 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (s && s.email) {
|
||||
const lr = await accounts.linkWallet(s.email, r.address);
|
||||
if (!lr.error) postbacks.convertFor(s.email, 'wallet', {}).catch(() => {});
|
||||
if (lr.error) return json(res, 400, lr);
|
||||
await auth.updateSession(s.token, { address: r.address, memberId });
|
||||
return json(res, 200, { ok: true, linked: true, address: r.address, memberId });
|
||||
@@ -1796,6 +1804,29 @@ const server = http.createServer(async (req, res) => {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const r = await rotator.stats(s.email, m[1]); return r ? json(res, 200, r, { 'Cache-Control': 'no-store' }) : json(res, 404, { error: 'No such rotation.' });
|
||||
}
|
||||
if (p === '/api/my/reports' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const days = Math.max(1, Math.min(365, Number(u.searchParams.get('days')) || 30));
|
||||
return json(res, 200, await rotator.summary(s.email, days), { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/postbacks' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
return json(res, 200, { postbacks: await postbacks.list(s.email), events: postbacks.EVENTS, key: postbacks.partnerKey(s.email), inboundUrl: 'https://' + SITE_HOST + '/pb/in', log: await postbacks.logFor(s.email, 40) }, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/postbacks' && 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); if (b.rotateKey) return json(res, 200, { ok: true, key: postbacks.rotateKey(s.email) });
|
||||
const r = await postbacks.create(s.email, b); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
m = /^\/api\/my\/postbacks\/([a-f0-9]{10})$/.exec(p);
|
||||
if (m && 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); const r = b.test ? await postbacks.test(s.email, m[1]) : await postbacks.update(s.email, m[1], b); return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
if (p === '/pb/in' && (req.method === 'GET' || req.method === 'POST')) { // partner-reported conversion against our click id
|
||||
const b = req.method === 'POST' ? await readBody(req).catch(() => ({})) : {}; for (const [k, v] of u.searchParams) if (b[k] == null) b[k] = v;
|
||||
const r = await postbacks.inbound(b.key, b); return json(res, r.error ? 400 : 200, r, { 'Cache-Control': 'no-store' });
|
||||
}
|
||||
if (p === '/api/my/carry' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const st = carry.status(); const me = s.email.toLowerCase();
|
||||
@@ -2809,6 +2840,9 @@ const server = http.createServer(async (req, res) => {
|
||||
if (p === '/disclaimer') return sendFile(res, path.join(PUBLIC_DIR, 'disclaimer.html'));
|
||||
if (p === '/my') return sendFile(res, path.join(PUBLIC_DIR, 'my.html'));
|
||||
if (p === '/links') return sendFile(res, path.join(PUBLIC_DIR, 'links.html')); // Control Room: the links workspace, first screen of the new front end (2026-09-29)
|
||||
if (p === '/reports') return sendFile(res, path.join(PUBLIC_DIR, 'reports.html'));
|
||||
if (p === '/team') return sendFile(res, path.join(PUBLIC_DIR, 'team.html'));
|
||||
if (p === '/wallet') return sendFile(res, path.join(PUBLIC_DIR, 'wallet.html'));
|
||||
if (p === '/admin') return sendFile(res, path.join(PUBLIC_DIR, 'admin.html'));
|
||||
if (p === '/shorts') return sendFile(res, path.join(PUBLIC_DIR, 'shorts.html'));
|
||||
if (p === '/plays') return sendFile(res, path.join(PUBLIC_DIR, 'plays.html'));
|
||||
|
||||
Reference in New Issue
Block a user