Network Weekend (Marty 2026-11-17): +3 board days per Boost bought Fri 11-27 00:00 CT to Tue 12-01 00:00 CT, ribbon, chatbot facts
weekend.js (WEEKEND_BOOST_DAYS=0 off, WEEKEND_NOW test clock); wire.js stacks SKU days + the bonus by the purchase's chain time, so it needs no contract change (the SKU holds 7 board days; a Boost is days, not views). /api/config, quote, order show the weekend days. netdeals.js + /assets/netweekend.js ribbon via common.js (not admin, never framed), common.js?v=3. Chatbot FACTS line and chatcore finish hook while live. qa/weekend.test.cjs; e2e 63/63. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,11 +29,14 @@ const fresh = (m, k) => { const t = m.get(k); return t && Date.now() - t < H24;
|
||||
|
||||
// ---- Boosts ----
|
||||
function purchases() { return Object.entries(store.state().purchases || {}).map(([key, x]) => Object.assign({ key }, x)); }
|
||||
// board days per unit of a Boost: the chain's SKU days, plus the Network Weekend bonus when it was bought in the window (weekend.js)
|
||||
const weekend = require('./weekend');
|
||||
const unitDays = b => (b.days || C().boost.days) + weekend.bonusDays((b.blockAt ? b.blockAt * 1000 : b.at) || 0);
|
||||
// when an ad's Boosts end: each unit adds boost.days, back to back from its purchase (or from the end of the one before)
|
||||
function boostedUntil(adId) {
|
||||
let until = 0;
|
||||
for (const b of purchases().filter(x => x.adId === Number(adId)).sort((a, b) => (a.at || 0) - (b.at || 0))) {
|
||||
const at = (b.blockAt ? b.blockAt * 1000 : b.at) || 0; until = Math.max(until, at) + (Number(b.qty) || 1) * (b.days || C().boost.days) * 86400000;
|
||||
const at = (b.blockAt ? b.blockAt * 1000 : b.at) || 0; until = Math.max(until, at) + (Number(b.qty) || 1) * unitDays(b) * 86400000;
|
||||
}
|
||||
return until;
|
||||
}
|
||||
@@ -45,7 +48,7 @@ function attach(rec) {
|
||||
function attachPending(owner, adId) { let n = 0; for (const x of Object.values(store.state().purchases || {})) if (x.buyer === owner && !x.adId) { x.adId = adId; n++; } if (n) store.save(); return n; }
|
||||
function boostView(b) {
|
||||
const until = b.adId ? boostedUntil(b.adId) : 0;
|
||||
return { key: b.key, tx: String(b.key).split(':')[0], orderId: b.orderId, at: (b.blockAt ? b.blockAt * 1000 : b.at) || null, adId: b.adId || null, qty: b.qty, days: (Number(b.qty) || 1) * (b.days || C().boost.days),
|
||||
return { key: b.key, tx: String(b.key).split(':')[0], orderId: b.orderId, at: (b.blockAt ? b.blockAt * 1000 : b.at) || null, adId: b.adId || null, qty: b.qty, days: (Number(b.qty) || 1) * unitDays(b), weekendDays: (Number(b.qty) || 1) * (unitDays(b) - (b.days || C().boost.days)),
|
||||
boostedUntil: until || null, status: !b.adId ? 'waiting-for-ad' : until > Date.now() ? 'on-top' : 'finished', resharer: b.resharer || null, resharerWei: b.resharerPaid || '0' };
|
||||
}
|
||||
|
||||
@@ -137,5 +140,5 @@ function setSecret(s) { SECRET = String(s); }
|
||||
const vtoken = vk => crypto.createHmac('sha256', SECRET).update('vt|' + vk + '|' + store.ctDay()).digest('hex').slice(0, 24);
|
||||
const vtokenOk = (vk, t) => typeof t === 'string' && t.length === 24 && crypto.timingSafeEqual(Buffer.from(t), Buffer.from(vtoken(vk)));
|
||||
|
||||
module.exports = { init, rebuild, purchases, boostedUntil, isBoosted, attach, attachPending, boostView, adCard, board, creditPicks, weekStats,
|
||||
module.exports = { unitDays, init, rebuild, purchases, boostedUntil, isBoosted, attach, attachPending, boostView, adCard, board, creditPicks, weekStats,
|
||||
canVisit, verify, click, vtoken, vtokenOk, setSecret, hostOf };
|
||||
|
||||
Reference in New Issue
Block a user