Stack POL Pro (Marty 2026-11-09): a one-time unlock for the member's stackpol.com page, new money only. Promo tools > Stack POL > Get Pro opens an order; the member's next ad package of $10 or more (mined after the order, by their own position) fulfils it, one package fulfils one order, credits never count (gamepass.js order book, persisted map 'stackpro', durable). The fulfilment marks pro[username] in stack-optin.json for the stackpol.com indexer. New Stack POL Pro achievement badge (badge-stackpro.jpg, ribbon 0.855), celebrated and posted like Game Pass. /my#promo?s=stackpol deep-links the tab (the Pro page's Unlock Pro button). Chatbot canned answer + prompt carry Pro. qa/stackpro.mjs 16/16; member walk 0 bugs; qa/gamepass.mjs has the same 7 date-based failures on the untouched HEAD.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -161,7 +161,7 @@ function loadOpenTokens() {
|
||||
const cutoff = Date.now() - 2 * 3600 * 1000; let n = 0;
|
||||
// durable maps are balances and orders, not short-lived tokens: restore every entry whatever its age. Before 2026-10-10 the
|
||||
// age filter silently dropped every PolyWarriors mint pass (no ts on the record) on each deploy; Orlando lost his.
|
||||
const DURABLE = new Set(['pwpasses', 'pwprizes', 'pworders', 'gkorders', 'sdorders', 'gamepass', 'gporders', 'gpprizes']);
|
||||
const DURABLE = new Set(['pwpasses', 'pwprizes', 'pworders', 'gkorders', 'sdorders', 'gamepass', 'gporders', 'gpprizes', 'stackpro']);
|
||||
for (const [name, m] of Object.entries(persistedMaps)) {
|
||||
for (const [k, v] of Object.entries(saved[name] || {})) if (v && (DURABLE.has(name) || Number(v.ts || 0) > cutoff)) { Map.prototype.set.call(m, k, v); n++; }
|
||||
}
|
||||
@@ -553,7 +553,7 @@ async function boot() {
|
||||
starter.onEvent(ev).catch(e => console.error('starter bonus', e.message));
|
||||
pwMintOnEvent(ev).catch(e => console.error('polywarriors mint', e.message));
|
||||
// the Friday bonus and the pass order first, then the Friday pass perk, which needs both results (Marty 2026-10-23)
|
||||
Promise.all([friday.onEvent(ev).catch(e => { console.error('friday bonus', e.message); return null; }), gamepass.onEvent(ev).catch(e => { console.error('gamepass order', e.message); return null; })])
|
||||
Promise.all([friday.onEvent(ev).catch(e => { console.error('friday bonus', e.message); return null; }), gamepass.onEvent(ev).then(r => { if (r && r.stackPro && r.email) stackProMark(r.email).catch(() => {}); return r; }).catch(e => { console.error('gamepass order', e.message); return null; })])
|
||||
.then(([bonus, gp]) => fridayPassPerk(ev, bonus, gp)).catch(e => console.error('friday pass perk', e.message));
|
||||
wednesday.onEvent(ev).catch(e => console.error('wednesday bonus', e.message));
|
||||
refuel.onIapPurchase(ev).catch(e => console.error('refuel streak', e.message)); // its own bonus, stacked on Friday/Wednesday; no-op while refuelStreak is off
|
||||
@@ -898,6 +898,13 @@ function readRaw(req, maxBytes) {
|
||||
req.on('error', reject);
|
||||
});
|
||||
}
|
||||
// Stack POL Pro paid (2026-11-09): mark the member in stack-optin.json so the stackpol.com indexer shows their LinkSpin links next run
|
||||
async function stackProMark(email) {
|
||||
const a = await accounts.byEmail(email); const un = String((a && a.username) || '').toLowerCase(); if (!un) return;
|
||||
const F = path.join(DATA_DIR, 'stack-optin.json'); let so = { users: {} }; try { so = JSON.parse(fs.readFileSync(F, 'utf8')); } catch (e) {}
|
||||
so.users = so.users || {}; so.pro = so.pro || {}; so.pro[un] = true; so.users[un] = true; so.updatedAt = Date.now();
|
||||
const tmp = F + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(so)); fs.renameSync(tmp, F);
|
||||
}
|
||||
function readBody(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let d = ''; let n = 0;
|
||||
@@ -1618,7 +1625,7 @@ async function telegramSendPhoto(chatId, jpeg, caption, threadId) {
|
||||
rq.on('error', () => resolve(false)); rq.on('timeout', () => { rq.destroy(); resolve(false); }); rq.end(body);
|
||||
});
|
||||
}
|
||||
const BADGE_META = { payouts: ['Spark', 'payouts switched on'], firstBuyer: ['Surge', 'first qualifying buyer'], level2: ['Circuit', 'two qualifying buyers, level 2 open'], level3: ['Nexus', 'five qualifying buyers, fully qualified'], fridays: ['Five Fridays', 'five Five Dollar Fridays in a row'], gamepass: ['Game Pass', 'Game Pass holder'],
|
||||
const BADGE_META = { payouts: ['Spark', 'payouts switched on'], firstBuyer: ['Surge', 'first qualifying buyer'], level2: ['Circuit', 'two qualifying buyers, level 2 open'], level3: ['Nexus', 'five qualifying buyers, fully qualified'], fridays: ['Five Fridays', 'five Five Dollar Fridays in a row'], gamepass: ['Game Pass', 'Game Pass holder'], stackpro: ['Stack POL Pro', 'Stack POL Pro page unlocked'],
|
||||
refuelStart: ['Engine Started', 'first monthly refuel'], refuel3: ['Refueled 3 months', 'three monthly refuels in a row'], refuel6: ['Refueled 6 months', 'six monthly refuels in a row'], refuel12: ['Refueled 12 months', 'twelve monthly refuels in a row'] };
|
||||
const BADGE_LOG = () => path.join(DATA_DIR, 'badge-posts.json');
|
||||
function badgeLog() { try { return JSON.parse(fs.readFileSync(BADGE_LOG(), 'utf8')); } catch (e) { return {}; } }
|
||||
@@ -3066,6 +3073,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (bc >= 5) reached.push('level3');
|
||||
try { if (out.memberId && friday.earnedBadge(out.memberId)) reached.push('fridays'); } catch (e) {} // five Five Dollar Fridays in a row
|
||||
try { if (out.email && gamepass.flag(out.email).until) reached.push('gamepass'); } catch (e) {} // ever held a Game Pass (2026-10-22)
|
||||
try { if (out.email && gamepass.stackPro(out.email)) reached.push('stackpro'); } catch (e) {} // owns Stack POL Pro (2026-11-09)
|
||||
try { if (out.email) for (const k of await refuel.badgesOf(out.email)) if (!reached.includes(k)) reached.push(k); } catch (e) {} // Monthly Refuel badges (2026-10-24)
|
||||
try { for (const k of await ads.milestonesOf(out.email)) if (!reached.includes(k)) reached.push(k); } catch (e) {} // a badge once earned stays earned
|
||||
out.milestonesReached = reached;
|
||||
@@ -3460,7 +3468,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const b = await readBody(req); const key = String(b.key || ''); const a = await accounts.byEmail(String(b.email || '').toLowerCase());
|
||||
if (!a || !BADGE_META[key]) return json(res, 400, { error: 'Unknown member or badge.' });
|
||||
if (!(await ads.milestonesOf(a.email)).includes(key) && !(key === 'gamepass' && gamepass.flag(a.email).until)) return json(res, 400, { error: 'That member has not unlocked that badge.' }); // the Game Pass badge is earned by holding a pass, recorded or not yet
|
||||
if (!(await ads.milestonesOf(a.email)).includes(key) && !(key === 'gamepass' && gamepass.flag(a.email).until) && !(key === 'stackpro' && gamepass.stackPro(a.email))) return json(res, 400, { error: 'That member has not unlocked that badge.' }); // the Game Pass badge is earned by holding a pass, recorded or not yet
|
||||
const jpeg = await badge.render(key, a.username || ('member #' + a.memberId)); if (!jpeg) return json(res, 500, { error: 'Render failed.' });
|
||||
const who = a.username ? '@' + a.username : 'member #' + a.memberId; const link = a.username ? 'instantadpay.com/join/' + a.username : 'instantadpay.com';
|
||||
const [label, sub] = BADGE_META[key];
|
||||
@@ -5160,11 +5168,15 @@ const server = http.createServer(async (req, res) => {
|
||||
const acct = await accounts.byEmail(s.email); const un = String((acct && acct.username) || '').toLowerCase();
|
||||
if (!un) return json(res, 400, { error: 'Pick a username first (Profile), then switch on your Stack POL page.' });
|
||||
const F = path.join(DATA_DIR, 'stack-optin.json'); let so = { users: {} }; try { so = JSON.parse(fs.readFileSync(F, 'utf8')); if (!so.users) so.users = {}; } catch (e) {}
|
||||
if (req.method === 'POST') {
|
||||
const b = await readBody(req); so.users[un] = !!b.on; so.updatedAt = Date.now();
|
||||
const tmp = F + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(so)); fs.renameSync(tmp, F);
|
||||
}
|
||||
return json(res, 200, { on: !!so.users[un], username: un, url: 'https://stackpol.com/' + un, wallet: !!(acct && acct.address) });
|
||||
let b = {}; if (req.method === 'POST') b = await readBody(req);
|
||||
let buy = null;
|
||||
if (req.method === 'POST' && b.pro === 'buy') buy = gamepass.buyStackPro(s.email); // Stack POL Pro: opens a waiting order, a $10+ package fulfils it
|
||||
else if (req.method === 'POST' && b.pro === 'cancel') gamepass.cancelStackOrder(s.email);
|
||||
else if (req.method === 'POST') so.users[un] = !!b.on;
|
||||
// the indexer reads Pro owners from this same file, so the page knows who gets their LinkSpin links shown
|
||||
so.pro = so.pro || {}; const pv = gamepass.stackProView(s.email); if (pv.pro) so.pro[un] = true; else delete so.pro[un];
|
||||
if (req.method === 'POST' || !!so.pro[un] !== !!pv.pro || pv.pro) { so.updatedAt = Date.now(); const tmp = F + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(so)); fs.renameSync(tmp, F); }
|
||||
return json(res, 200, { on: !!so.users[un], username: un, url: 'https://stackpol.com/' + un, wallet: !!(acct && acct.address), pro: pv, buy });
|
||||
}
|
||||
if (p === '/api/my/inbox' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req);
|
||||
|
||||
Reference in New Issue
Block a user