Banner Spins for Viral Banner Blitz (Marty 2026-11-14: "make sure Viral Banner Blitz incorporates banner spins that could be pulled in just like downline banners"). /api/partner/bl/spins takes { site: 'vbb' }: 125x125 + 250x250 spins, a "Viral Banner Blitz" source (new catalog template viralbannerblitz), and { username } (the member's network username) when no account holds the wallet; vbb only. Answers now carry host and each spin's size. Downline Banners' calls are unchanged (468x60, wallet only). Same NETWORK_SSO_SECRET signature. qa/partner-spins.test.mjs 13/13 (local copy, JSON store); networksso ALL PASSED; hubsync 15 checks ok
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3074,6 +3074,8 @@ const server = http.createServer(async (req, res) => {
|
||||
// { wallet } lists the 468x60 Banner Spins of the LinkSpin account holding that wallet. { wallet, spinId } also makes sure the
|
||||
// account has a "Downline Banners" source (catalog template), tags the spin with it when the spin has no source yet, and
|
||||
// answers the image + click URLs with the board's macros. Nothing else about the account is read or changed.
|
||||
// Viral Banner Blitz (Marty 2026-11-14) calls the same endpoint with { site: 'vbb' }: 125x125 and 250x250 spins, its own
|
||||
// "Viral Banner Blitz" source, and { username } (its network username) when no account holds the wallet.
|
||||
if (p === '/api/partner/bl/spins' && req.method === 'POST') {
|
||||
let raw = ''; try { raw = await new Promise((ok, no) => { let d = ''; req.on('data', c => { d += c; if (d.length > 4096) { req.destroy(); no(new Error('too big')); } }); req.on('end', () => ok(d)); req.on('error', no); }); } catch (e) { return json(res, 400, { error: 'bad body' }); }
|
||||
const sec = String(process.env.NETWORK_SSO_SECRET || '').trim(); const ts = String(req.headers['x-net-ts'] || ''); const sig = String(req.headers['x-net-sig'] || '');
|
||||
@@ -3082,18 +3084,21 @@ const server = http.createServer(async (req, res) => {
|
||||
if (sig.length !== want.length || !crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(want))) return json(res, 401, { error: 'unauthorized' });
|
||||
let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return json(res, 400, { error: 'bad json' }); }
|
||||
const w = String(b.wallet || '').trim().toLowerCase(); if (!/^0x[0-9a-f]{40}$/.test(w)) return json(res, 400, { error: 'wallet' });
|
||||
const a = await accounts.byAddress(w).catch(() => null);
|
||||
const vbb = b.site === 'vbb'; const P = vbb ? { sizes: ['125x125', '250x250'], tpl: 'viralbannerblitz', name: 'Viral Banner Blitz', site: 'https://viralbannerblitz.com', what: '125x125 (or 250x250)' }
|
||||
: { sizes: ['468x60'], tpl: 'downlinebanners', name: 'Downline Banners', site: 'https://downlinebanners.com', what: '468x60' };
|
||||
let a = await accounts.byAddress(w).catch(() => null);
|
||||
if ((!a || !a.email) && vbb && b.username) a = await accounts.byUsername(String(b.username)).catch(() => null);
|
||||
if (!a || !a.email) return json(res, 200, { account: false });
|
||||
const spins = (await bannerspin.list(a.email)).filter(x => x.size === '468x60' && !x.adminOff);
|
||||
const spins = (await bannerspin.list(a.email)).filter(x => P.sizes.includes(x.size) && !x.adminOff);
|
||||
const hs = domains.hosts(); const host = (hs[0] && hs[0].host) || SITE_HOST;
|
||||
const out = { account: true, username: a.username || null, spins: spins.map(x => ({ id: x.id, name: x.name, code: x.code, paused: !!x.paused, banners: (x.banners || []).length, sourceId: x.sourceId || null })) };
|
||||
const out = { account: true, username: a.username || null, host, spins: spins.map(x => ({ id: x.id, name: x.name, code: x.code, size: x.size, paused: !!x.paused, banners: (x.banners || []).length, sourceId: x.sourceId || null })) };
|
||||
if (b.spinId != null) {
|
||||
const sp = spins.find(x => x.id === Number(b.spinId)); if (!sp) return json(res, 404, { error: 'No such 468x60 Banner Spin on this LinkSpin account.' });
|
||||
let src = ((await sources.list(a.email)).sources || []).find(x => x.template === 'downlinebanners');
|
||||
if (!src) { const r = await sources.create(a.email, { template: 'downlinebanners', name: 'Downline Banners', site: 'https://downlinebanners.com' }); if (r.error) return json(res, 400, { error: r.error }); src = r.source || ((await sources.list(a.email)).sources || []).find(x => x.template === 'downlinebanners'); }
|
||||
const sp = spins.find(x => x.id === Number(b.spinId)); if (!sp) return json(res, 404, { error: 'No such ' + P.what + ' Banner Spin on this LinkSpin account.' });
|
||||
let src = ((await sources.list(a.email)).sources || []).find(x => x.template === P.tpl);
|
||||
if (!src) { const r = await sources.create(a.email, { template: P.tpl, name: P.name, site: P.site }); if (r.error) return json(res, 400, { error: r.error }); src = r.source || ((await sources.list(a.email)).sources || []).find(x => x.template === P.tpl); }
|
||||
let tagged = false;
|
||||
if (src && !sp.sourceId) { const r = await bannerspin.update(a.email, sp.id, { sourceId: src.id }); tagged = !r.error; }
|
||||
out.use = { spinId: sp.id, name: sp.name, img: 'https://' + host + '/i/' + sp.code + '.gif', link: 'https://' + host + '/c/' + sp.code + '?clickid={clickid}&placement={spot}&s1={type}',
|
||||
out.use = { spinId: sp.id, name: sp.name, size: sp.size, img: 'https://' + host + '/i/' + sp.code + '.gif', link: 'https://' + host + '/c/' + sp.code + '?clickid={clickid}&placement={spot}&s1={type}',
|
||||
sourceId: src ? src.id : null, tagged, otherSource: !!(sp.sourceId && src && sp.sourceId !== src.id) };
|
||||
}
|
||||
return json(res, 200, out, { 'Cache-Control': 'no-store' });
|
||||
|
||||
Reference in New Issue
Block a user