LinkSpin Banner Spins in Viral Banner Blitz (Marty 2026-11-14: "make sure Viral Banner Blitz incorporates banner spins that could be pulled in just like downline banners"), the Downline Banners pattern. lsspins.js calls LinkSpin's /api/partner/bl/spins with { site: 'vbb' }, signed with NETWORK_SSO_SECRET (by wallet; the network username too for network-verified members). My Banners: "Use my LinkSpin Banner Spin" lists the member's 125x125 / 250x250 spins (GET /api/my/lsspins) and one tap posts one (POST /api/my/banners { spinId }): one credit, same credit + waiting rules, image + link from LinkSpin's signed answer only (https, same host), the image is the spin's rotating image and the link its click link, so clicks count in LinkSpin Reports under a Viral Banner Blitz source. /go/ fills {clickid}, {spot} (banner number) and {type} (loop or waiting). Splash: the loop's open places (one stays "post yours") and the empty waiting line show members' Banner Spins (SPIN tiles, refreshed every 10 minutes, one per member, none for a member with a banner on the page, no image twice, same picks for 2 minutes); they are never in the loop list, never shift it, cycle or earn, and a note says so. Admin status: lsSpins. LS_PARTNER_URL for the smoke stand-in. common.js?v=4, splash.js?v=3, my.js?v=3, vbb.css?v=5. Smoke 227/227 (35 new, stand-in LinkSpin), chain 29/29. Needs LinkSpin 5d630ec.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ const shop = require('./shop');
|
||||
const promokit = require('./promokit'); // promo kit feed /api/promo-kit + the /promote page (2026-11-14)
|
||||
const hubreport = require('./hubreport'); // network hub report by wallet (off unless HUB_ENABLED)
|
||||
const prize = require('./prize');
|
||||
const lsspins = require('./lsspins'); // LinkSpin Banner Spins: post one as a banner, and fill the splash's open places (2026-11-14)
|
||||
|
||||
const PUB = path.join(__dirname, 'public');
|
||||
const UPL = path.join(C.dataDir, 'uploads');
|
||||
@@ -163,7 +164,7 @@ function grantDaily(m) {
|
||||
function myData(addr) {
|
||||
const m = store.member(addr);
|
||||
const banners = store.bannersOf(addr).slice().reverse().map(b => Object.assign({ id: b.id, img: b.img, link: b.link, createdAt: b.createdAt, cycledAt: b.cycledAt || null, clicks: b.clicks || 0,
|
||||
look: !!b.look, teaser: b.look ? (b.teaser || '') : '', teaserDefault: loop.hostOf(b.link) }, loop.placeOf(b)));
|
||||
look: !!b.look, teaser: b.look ? (b.teaser || '') : '', teaserDefault: b.spin ? b.spin.name : loop.hostOf(b.link), spin: b.spin ? { name: b.spin.name, size: b.spin.size } : null }, loop.placeOf(b)));
|
||||
const rewards = store.ledger().filter(e => e.owner === m.address);
|
||||
const shareName = m.username || m.address;
|
||||
return { address: m.address, username: m.username, credits: m.credits, freeCreditCap: C.freeCreditCap, freeToday: m.freeDay === store.ctDay(), netVerified: netVerified(m),
|
||||
@@ -260,7 +261,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const k = visitorKey(req) + ':' + b.id; const t = clickSeen.get(k);
|
||||
if (!t || Date.now() - t > 3600000) { clickSeen.set(k, Date.now()); if (clickSeen.size > 100000) clickSeen.clear(); b.clicks = (b.clicks || 0) + 1; store.saveBanner(b); store.bump('clicks'); }
|
||||
}
|
||||
res.writeHead(302, { Location: b.link, 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
|
||||
res.writeHead(302, { Location: clickLink(b), 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +289,7 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
// past weeks' prize winners with their transactions (paid weeks only)
|
||||
if (p === '/api/prizes' && req.method === 'GET') return json(res, 200, { current: prizes(), week: store.ctWeek(), past: prize.history(12), explorer: C.explorer }, { 'Cache-Control': 'public, max-age=30' });
|
||||
if (p === '/api/splash' && req.method === 'GET') return json(res, 200, loop.view(24), { 'Cache-Control': 'no-store' });
|
||||
if (p === '/api/splash' && req.method === 'GET') { const v = loop.view(24); v.fill = splashFill(); return json(res, 200, v, { 'Cache-Control': 'no-store' }); }
|
||||
if (p === '/api/leaders' && req.method === 'GET') {
|
||||
const out = loop.leaders(null, 10);
|
||||
const fmt = r => ({ name: r.username ? '@' + r.username : r.address.slice(0, 6) + '...' + r.address.slice(-4), visitors: r.visitors, sources: r.sources });
|
||||
@@ -404,6 +405,12 @@ const server = http.createServer(async (req, res) => {
|
||||
if (t.length > 40) return json(res, 400, { error: 'Keep the teaser to 40 characters.' });
|
||||
bn.teaser = t; store.saveBanner(bn); return json(res, 200, { ok: true, teaser: t || loop.hostOf(bn.link) });
|
||||
}
|
||||
// the member's LinkSpin Banner Spins in a size the loop shows (125x125, or 250x250 for sharp screens)
|
||||
if (p === '/api/my/lsspins' && req.method === 'GET') {
|
||||
if (limited(req, 'lsspins', 120, 3600000)) return json(res, 429, { error: 'Too many requests this hour.' });
|
||||
const r = await lsspins.list(me, lsName(me)); if (r.error) return json(res, 502, r);
|
||||
return json(res, 200, { account: !!r.account, username: r.username || null, spins: (r.spins || []).filter(x => ['125x125', '250x250'].includes(x.size)).map(x => ({ id: x.id, name: x.name, size: x.size || null, paused: !!x.paused, banners: x.banners || 0 })) });
|
||||
}
|
||||
if (p === '/api/my/upload' && req.method === 'POST') {
|
||||
if (limited(req, 'upload', 40, 3600000)) return json(res, 429, { error: 'Too many uploads this hour.' });
|
||||
let buf; try { buf = await readRaw(req, safety.MAX_UPLOAD + 1); } catch (e) { return json(res, 400, { error: 'The file is over 100 KB.' }); }
|
||||
@@ -416,6 +423,20 @@ const server = http.createServer(async (req, res) => {
|
||||
if (m.credits < 1) return json(res, 400, { error: 'You have no post credits. A free credit arrives each day you sign in.' });
|
||||
const waiting = store.bannersOf(me).filter(x => x.state === 'queued').length;
|
||||
if (waiting >= C.maxQueuedPerMember) return json(res, 400, { error: 'You already have ' + waiting + ' banners waiting. Post again when one enters the loop.' });
|
||||
// a LinkSpin Banner Spin (2026-11-14): image + link come from LinkSpin's signed answer, never from the browser. The image is the
|
||||
// spin's rotating image on LinkSpin (not copied: it changes on every view) and the link its click link (clicks count in
|
||||
// LinkSpin Reports); LinkSpin checked the spin's images and links, so the frame probe (it would count a click) is skipped.
|
||||
if (b.spinId != null) {
|
||||
const r = await lsspins.use(me, lsName(me), b.spinId);
|
||||
if (r.error || !r.use) return json(res, 400, { error: r.error || (r.account === false ? 'No LinkSpin account holds this wallet yet.' : 'Could not use that Banner Spin.') });
|
||||
if (!['125x125', '250x250'].includes(r.use.size)) return json(res, 400, { error: 'Use a 125x125 (or 250x250) Banner Spin.' });
|
||||
const ic = safety.checkLink(r.use.img, 'Banner Spin image'); const sl = safety.checkLink(r.use.link, 'Banner Spin link');
|
||||
if (ic.error || sl.error || new URL(ic.url).hostname !== new URL(sl.url).hostname) return json(res, 400, { error: 'LinkSpin sent a link we cannot use. Try again in a minute.' });
|
||||
if (store.member(me).credits < 1) return json(res, 400, { error: 'You have no post credits.' });
|
||||
m.credits -= 1;
|
||||
const nb = loop.post(me, ic.url, sl.url, 'credit', { id: Number(r.use.spinId), name: String(r.use.name || '').slice(0, 60), size: r.use.size });
|
||||
return json(res, 200, { ok: true, banner: Object.assign({ id: nb.id }, loop.placeOf(nb)), credits: m.credits, otherSource: !!r.use.otherSource });
|
||||
}
|
||||
const lk = safety.checkLink(b.link, 'Target link'); if (lk.error) return json(res, 400, lk);
|
||||
let img = String(b.img || '').trim();
|
||||
if (/^\/u\/[a-z0-9-]+\.(png|jpg|gif)$/.test(img)) {
|
||||
@@ -445,7 +466,7 @@ const server = http.createServer(async (req, res) => {
|
||||
queue: { length: S.queue.length, next: S.queue.slice(0, 20) }, progress: S.progress, held: S.progress >= C.perShift && !S.queue.length,
|
||||
today: { visits: t.visits || 0, shifts: t.shifts || 0, cycles: t.cycles || 0, posts: t.posts || 0, clicks: t.clicks || 0 },
|
||||
totals: S.totals, ledger: { entries: L.length, views: L.reduce((x, e) => x + e.views, 0), viewsByStatus: byStatus, credited: 0 },
|
||||
members: store.members().length, banners: S.banners.length, visitsKept: store.visits().length, shop: shop.view(), prize: prize.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
|
||||
members: store.members().length, banners: S.banners.length, visitsKept: store.visits().length, shop: shop.view(), prize: prize.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), lsSpins: lsspins.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
|
||||
}
|
||||
// old username -> network username map for the old-link redirects: { oldrefs: { old: network } } replaces the whole map
|
||||
if (p === '/api/admin/oldrefs' && req.method === 'POST') {
|
||||
@@ -484,6 +505,26 @@ const server = http.createServer(async (req, res) => {
|
||||
if (!res.headersSent) json(res, 500, { error: 'Server error' });
|
||||
}
|
||||
});
|
||||
// the network username LinkSpin may look the member up by when no LinkSpin account holds this wallet: network-verified members only
|
||||
const lsName = addr => { const m = store.member(addr); return m && netVerified(m) && m.username ? m.username : null; };
|
||||
// tracking macros in a banner link, filled on every click: {clickid} a fresh id, {spot} the banner number, {type} loop or waiting
|
||||
const MACRO = /\{(clickid|spot|type)\}|%7B(clickid|spot|type)%7D/gi;
|
||||
function clickLink(b) {
|
||||
const l = String(b.link || ''); if (!l.match(MACRO)) return l;
|
||||
const v = { clickid: crypto.randomBytes(8).toString('hex'), spot: String(b.id), type: b.state === 'queued' ? 'waiting' : 'loop' };
|
||||
return l.replace(MACRO, (x, a, c) => v[(a || c).toLowerCase()]);
|
||||
}
|
||||
// members' Banner Spins on the splash: the loop's open places (one place always stays "post yours") and, while nobody waits, the
|
||||
// waiting line. Never in the loop list: no shift, no cycle, no reward. Same picks for 2 minutes, so the page does not reshuffle.
|
||||
let fillCache = { key: '', at: 0, out: { loop: [], queue: [] } };
|
||||
function splashFill() {
|
||||
const S = store.state(); const ids = S.loop.concat(S.queue.slice(0, 24)); const bs = ids.map(id => store.banner(id)).filter(Boolean);
|
||||
const open = Math.max(0, C.loopSize - S.loop.length - 1), queueSlots = S.queue.length ? 0 : 8;
|
||||
const key = ids.join(',') + '|' + open + '|' + queueSlots + '|' + lsspins.view().fill + '|' + lsspins.view().at;
|
||||
if (fillCache.key === key && Date.now() - fillCache.at < 120000) return fillCache.out;
|
||||
const out = lsspins.fill({ openPlaces: open, queueSlots, pageOwners: bs.map(b => b.owner), pageImgs: bs.map(b => b.img) });
|
||||
fillCache = { key, at: Date.now(), out }; return out;
|
||||
}
|
||||
const validSku = sku => sku === C.lookSku || C.packs.some(x => x.sku === sku);
|
||||
const skuUsd = sku => sku === C.lookSku ? C.lookUsd : (C.packs.find(x => x.sku === sku) || {}).usd || 0;
|
||||
function saveUpload(owner, buf, ext) {
|
||||
@@ -501,6 +542,9 @@ function saveUpload(owner, buf, ext) {
|
||||
hubreport.init({ dataDir: C.dataDir, purchases: () => Object.entries((store.state() || {}).purchases || {}).map(([key, x]) => Object.assign({ key }, x)) });
|
||||
shop.init(C); // inert without CONTRACT_ADDRESS + CHAIN_RPC (watcher) / KEEPER_KEY (vouchers)
|
||||
prize.init(C); // prepares last week's payout plan; pays only on an admin's approval (PRIZE_KEY)
|
||||
// fill spins: members seen in the last 60 days (most recent 400), one LinkSpin call each every 10 minutes
|
||||
lsspins.init({ base: () => C.lsPartnerBase, members: () => store.members().filter(m => Date.now() - (m.lastSeen || m.joinedAt || 0) < 60 * 86400000)
|
||||
.sort((a, b) => (b.lastSeen || 0) - (a.lastSeen || 0)).slice(0, 400) });
|
||||
setInterval(() => { if (store.pruneVisits()) loop.rebuildIndex(); }, 3600000).unref();
|
||||
server.listen(C.port, () => console.log('Viral Banner Blitz on :' + C.port + ' loop ' + C.loopSize + ', ' + C.perShift + ' visitors per shift, store: ' + (docstore.isOn() ? 'MySQL documents' : 'files (prototype mode)')));
|
||||
})().catch(e => { console.error('start failed:', e.message); process.exit(1); });
|
||||
|
||||
Reference in New Issue
Block a user