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:
@@ -8,7 +8,7 @@ const path = require('path');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
let PUBLIC_DIR = null;
|
||||
const ART = { payouts: { file: 'badge-spark.jpg', ribbonY: 0.728 }, firstBuyer: { file: 'badge-surge.jpg', ribbonY: 0.76 }, level2: { file: 'badge-circuit.jpg', ribbonY: 0.72 }, level3: { file: 'badge-nexus.jpg', ribbonY: 0.73 }, fridays: { file: 'badge-fridays.jpg', ribbonY: 0.719 }, gamepass: { file: 'badge-gamepass.jpg', ribbonY: 0.84 } , refuelStart: { file: 'badge-refuelstart.jpg', ribbonY: 0.735 }, refuel3: { file: 'badge-refuel3.jpg', ribbonY: 0.783 }, refuel6: { file: 'badge-refuel6.jpg', ribbonY: 0.716 }, refuel12: { file: 'badge-refuel12.jpg', ribbonY: 0.744 } };
|
||||
const ART = { payouts: { file: 'badge-spark.jpg', ribbonY: 0.728 }, firstBuyer: { file: 'badge-surge.jpg', ribbonY: 0.76 }, level2: { file: 'badge-circuit.jpg', ribbonY: 0.72 }, level3: { file: 'badge-nexus.jpg', ribbonY: 0.73 }, fridays: { file: 'badge-fridays.jpg', ribbonY: 0.719 }, gamepass: { file: 'badge-gamepass.jpg', ribbonY: 0.84 }, stackpro: { file: 'badge-stackpro.jpg', ribbonY: 0.855 }, refuelStart: { file: 'badge-refuelstart.jpg', ribbonY: 0.735 }, refuel3: { file: 'badge-refuel3.jpg', ribbonY: 0.783 }, refuel6: { file: 'badge-refuel6.jpg', ribbonY: 0.716 }, refuel12: { file: 'badge-refuel12.jpg', ribbonY: 0.744 } };
|
||||
let FONT;
|
||||
function font() {
|
||||
if (FONT !== undefined) return FONT;
|
||||
|
||||
+3
-3
@@ -38,9 +38,9 @@ const KNOWLEDGE_DATE = '2026-11-09'; // bump whenever the canned answers / promp
|
||||
const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i;
|
||||
const CANNED = [
|
||||
// Stack POL (2026-11-09): stackpol.com, every POL payout across the network on one page; members opt in to a page in Promo tools
|
||||
{ id: 'stack-pol', title: 'Stack POL', q: ['What is Stack POL?', 'How do I get my Stack POL page?', 'What is stackpol.com?'], tags: ['stack pol', 'stackpol', 'payouts', 'ledger', 'promo tools'],
|
||||
{ id: 'stack-pol', title: 'Stack POL', q: ['What is Stack POL?', 'How do I get my Stack POL page?', 'What is stackpol.com?'], tags: ['stack pol', 'stackpol', 'payouts', 'ledger', 'promo tools', 'stack pol pro', 'pro'],
|
||||
re: /\b(stack ?pol|stackpol(\.com)?)\b/i,
|
||||
a: 'Stack POL (https://stackpol.com) adds up every POL payout in the network: InstantAdPay and LinkSpin referral payments and the rewards from every game that pays POL. It shows the network total, one page per program, and a public ledger of the latest payouts with the username and a Polygonscan link for every payment. It refreshes every 5 minutes. To get your own page, open Promo tools, tap the Stack POL tab and switch on "Show my Stack POL page". It appears at stackpol.com/your-username within 5 minutes and carries your referral link on every program card. Link a wallet so your payouts can be added up. Switch it off any time. The totals are what members were paid, not a promise of what anyone will earn.' },
|
||||
a: 'Stack POL (https://stackpol.com) adds up every POL payout in the network: InstantAdPay and LinkSpin referral payments and the rewards from every game that pays POL. It shows the network total, one page per program, and a public ledger of the latest payouts with the username and a Polygonscan link for every payment. It refreshes every 5 minutes. To get your own page, open Promo tools, tap the Stack POL tab and switch on "Show my Stack POL page". It appears at stackpol.com/your-username within 5 minutes and carries your referral link on every program card. Link a wallet so your payouts can be added up. Switch it off any time. Stack POL Pro is a one-time upgrade: your page then shows your own LinkSpin Banner Spins in its ad spots and your spin links, a purple QR code that opens your page, and blog articles opened from your page show your banners and use your referral links on every button. To get it, tap Get Pro in the Stack POL tab, then buy any ad package of $10 or more; Pro switches on when that package settles on chain and you keep every credit of the package. Credits never unlock it. Pro owners also get the Stack POL Pro badge. The totals are what members were paid, not a promise of what anyone will earn.' },
|
||||
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold one time. The prices and whether they are on sale live in settings, so
|
||||
// this answer names neither; heroesFact() gives the AI the live state.
|
||||
{ id: 'sov-bonus-heroes', title: 'Shards of Valor bonus heroes', q: ['What are the bonus heroes in Shards of Valor?', 'How do I get Kestrel, Valda, Morag or Roland?', 'Is the hero a subscription?'], tags: ['shards of valor', 'heroes', 'bonus heroes', 'kestrel', 'valda', 'morag', 'roland', 'party'],
|
||||
@@ -337,7 +337,7 @@ function systemPrompt(kbBlock) {
|
||||
|
||||
FACTS:
|
||||
- LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company-paid, off-chain decision, on-chain payment. 3% of every package purchase (the POL actually paid) goes to the buyer's 4th upline on the contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = direct referral with a $20+ purchase, same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; the company account (#1) or no qualified upline = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId), shown in Earnings as 'Level 4 override' with a Polygon link and announced by email and an on-site notice. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split 50/20/10 is unchanged. Never promise amounts.
|
||||
- STACK POL (LIVE 2026-11-09, https://stackpol.com): one site that adds up every POL payout in the network (InstantAdPay and LinkSpin TierPaid referral payments plus every game's payouts), refreshed every 5 minutes, with per-program pages (/earn/<program>), a public ledger showing each payout's username and Polygonscan link, and a blog. Members get a public page at stackpol.com/<username> by switching on 'Show my Stack POL page' in Promo tools > Stack POL; it is off until they switch it on. It never holds money. Totals are past payouts, never a promise of earnings.
|
||||
- STACK POL (LIVE 2026-11-09, https://stackpol.com): one site that adds up every POL payout in the network (InstantAdPay and LinkSpin TierPaid referral payments plus every game's payouts), refreshed every 5 minutes, with per-program pages (/earn/<program>), a public ledger showing each payout's username and Polygonscan link, and a blog. Members get a public page at stackpol.com/<username> by switching on 'Show my Stack POL page' in Promo tools > Stack POL; it is off until they switch it on. It never holds money. STACK POL PRO (2026-11-09): one-time unlock, NEW MONEY only: Promo tools > Stack POL > Get Pro opens an order, the member's next package of $10 or more (bought after the order, by their own position) fulfils it; credits never count; one package fulfils one order. Pro pages show the member's own LinkSpin Banner Spins in the ad spots (network zones otherwise), their spin links, a purple QR code to the page, a 'Want a personalized page like this?' button, and articles opened from the page (?ref=<username>) use the member's referral on every call to action. Pro owners get the Stack POL Pro badge. Totals are past payouts, never a promise of earnings.
|
||||
${passTiersFact()}${heroesFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}${bixFact()}${turkeydropFact()}${sovTestFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref=<username> link.
|
||||
- HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time.
|
||||
- PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=<username>; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/<username>. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide.
|
||||
|
||||
+35
-8
@@ -82,7 +82,7 @@ const HERO_DEF = Object.fromEntries(HERO_DEFS.map(d => [d.key, d]));
|
||||
const HERO_BUNDLE_DEFAULT = 'valda,morag,roland';
|
||||
|
||||
let R = null; // deps from server.js
|
||||
let passes, orders, prizes; // durable persisted maps (server.js open-tokens store, DURABLE set)
|
||||
let passes, orders, prizes, stackpro; // stackpro: Stack POL Pro owners, email -> { ts, tx, cents, order } (2026-11-09). durable persisted maps (server.js open-tokens store, DURABLE set)
|
||||
let L = null; // the cap ledger: { members: { email: { days: {}, deferred: {}, weeks: {} } }, refs: { 'game:ref': {...} } }
|
||||
let saveTimer = null;
|
||||
|
||||
@@ -155,6 +155,7 @@ function init(deps) {
|
||||
passes = R.persistedMap('gamepass');
|
||||
orders = R.persistedMap('gporders');
|
||||
prizes = R.persistedMap('gpprizes');
|
||||
stackpro = R.persistedMap('stackpro');
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -191,7 +192,7 @@ function extend(e, via, extra, now, tier) {
|
||||
passes.set(e, writeTiers(cur, T, { bought, ts: t }));
|
||||
return { until, days: tc.days, tier };
|
||||
}
|
||||
function waitingOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind !== 'hero') out.push(Object.assign({ order: k }, o, { tier: tierOk(o.tier) ? o.tier : 'weekly' })); return out; }
|
||||
function waitingOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind !== 'hero' && o.kind !== 'stackpro') out.push(Object.assign({ order: k }, o, { tier: tierOk(o.tier) ? o.tier : 'weekly' })); return out; }
|
||||
function waitingOrder(e, tier) { return waitingOrders(e).find(o => o.tier === (tier || 'weekly')) || null; }
|
||||
// the admin's tier test: drop a waiting order that was opened for testing, so a later real package never fulfils it by surprise
|
||||
function cancelOrder(email, tier) {
|
||||
@@ -259,6 +260,26 @@ function buy(email, now, tier, opts) {
|
||||
message: (tier === 'weekly' ? 'Your Game Pass' : 'Your ' + name + ' pass') + ' starts the moment your next package of $' + pkg + ' or more settles on chain. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your ads.' };
|
||||
}
|
||||
|
||||
// Stack POL Pro (Marty 2026-11-09): a one-time unlock for the member's stackpol.com page (their LinkSpin Banner Spins and spin links
|
||||
// on the page, the shareable stack card). Like a pass or a hero it is NEW MONEY only: "Get Pro" opens a waiting order, and the next
|
||||
// package purchase of $10 or more by one of the member's own positions fulfils it (onEvent). Never credits, never direct POL; the
|
||||
// member keeps every credit of the package and the sponsor line is paid on chain as usual. Owned for good once paid.
|
||||
const STACK_PRO_CENTS = 1000;
|
||||
function stackOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind === 'stackpro') out.push(Object.assign({ order: k }, o)); return out; }
|
||||
function stackPro(email) { const e = String(email || '').toLowerCase(); return stackpro.get(e) || null; }
|
||||
function stackProView(email) { const e = String(email || '').toLowerCase(); const own = stackpro.get(e) || null; const w = stackOrders(e)[0] || null; return { pro: !!own, since: own ? own.ts : null, waiting: !!w, order: w ? w.order : null, usd: STACK_PRO_CENTS / 100 }; }
|
||||
function buyStackPro(email, now) {
|
||||
const e = String(email || '').toLowerCase(); const t = now || Date.now();
|
||||
if (stackpro.get(e)) return { ok: true, pro: true };
|
||||
let w = stackOrders(e)[0]; const reused = !!w;
|
||||
if (!w) { const k = 'sp-' + t.toString(36) + '-' + Math.random().toString(36).slice(2, 8); orders.set(k, { status: 'waiting', email: e, ts: t, kind: 'stackpro' }); w = Object.assign({ order: k }, orders.get(k)); console.log('stack pro order opened', e, k); }
|
||||
return { ok: false, needPay: true, payUrl: '/my?from=stackpro#buy', order: w.order, orderTs: w.ts, reused, usd: STACK_PRO_CENTS / 100, package: packageFor(STACK_PRO_CENTS / 100),
|
||||
message: 'Stack POL Pro switches on the moment your next package of $10 or more settles on chain. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your ads.' };
|
||||
}
|
||||
function cancelStackOrder(email) { const e = String(email || '').toLowerCase(); const w = stackOrders(e)[0]; if (!w) return { ok: true }; orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'cancelled', cancelledAt: Date.now() })); return { ok: true, order: w.order }; }
|
||||
function compStackPro(email, on, note) { const e = String(email || '').toLowerCase(); if (on) stackpro.set(e, { ts: Date.now(), via: 'comp', note: String(note || '').slice(0, 120) }); else stackpro.delete(e); return { ok: true, pro: !!on }; }
|
||||
function stackProOwners() { return [...stackpro.keys()]; }
|
||||
|
||||
// A package purchase landing on chain fulfils one of this account's waiting orders: the highest-priced one the package covers.
|
||||
// Rules (2026-10-22): the buyer must be one of this account's own positions (main member id or a linked position); the purchase must
|
||||
// be mined AFTER the order was opened (block time, ORDER_SKEW_MS for clock drift); one pass per purchase of $5 or more; each tx used
|
||||
@@ -288,15 +309,21 @@ async function minedAt(ev) { // block time in ms; the indexed-at time only when
|
||||
async function onEvent(ev) {
|
||||
if (!ev || ev.type !== 'Purchase' || (ev.priceCents || 0) < 500) return null;
|
||||
const c = cfg(); const cents = ev.priceCents || 0;
|
||||
if (!TIERS.some(k => cents >= c.tiers[k].price) && !heroOrderPrices(c).some(x => cents >= x)) return null;
|
||||
if (!TIERS.some(k => cents >= c.tiers[k].price) && !heroOrderPrices(c).some(x => cents >= x) && cents < STACK_PRO_CENTS) return null;
|
||||
const e = await ownerOf(ev); if (!e) return null;
|
||||
if (!waitingOrders(e).length && !heroOrders(e).length) return null;
|
||||
if (!waitingOrders(e).length && !heroOrders(e).length && !stackOrders(e).length) return null;
|
||||
if (txUsed(ev.tx)) return null; // each purchase counts once, everywhere
|
||||
const at = await minedAt(ev);
|
||||
// one package fulfils ONE order, pass or bonus hero (2026-11-05): the highest-priced one it covers, then the oldest
|
||||
const all = waitingOrders(e).map(o => Object.assign({ price: c.tiers[o.tier].price }, o)).concat(heroOrders(e).filter(o => heroOrderOpen(e, o.hero)).map(o => Object.assign({ price: heroOrderPrice(c, o.hero) }, o)));
|
||||
const all = waitingOrders(e).map(o => Object.assign({ price: c.tiers[o.tier].price }, o)).concat(heroOrders(e).filter(o => heroOrderOpen(e, o.hero)).map(o => Object.assign({ price: heroOrderPrice(c, o.hero) }, o))).concat(stackpro.get(e) ? [] : stackOrders(e).map(o => Object.assign({ price: STACK_PRO_CENTS }, o)));
|
||||
const w = all.filter(o => cents >= o.price && at + ORDER_SKEW_MS >= o.ts).sort((x, y) => y.price - x.price || x.ts - y.ts)[0];
|
||||
if (!w) { console.log('gamepass: package', String(ev.tx).slice(0, 12), 'by', e, 'fulfils no order (bought before the order or too small)'); return null; }
|
||||
if (w.kind === 'stackpro') {
|
||||
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
|
||||
stackpro.set(e, { ts: (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()), via: 'package', tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0 });
|
||||
console.log('stack pro fulfilled by package', e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents');
|
||||
return { order: w.order, stackPro: true, email: e };
|
||||
}
|
||||
if (w.kind === 'hero') {
|
||||
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
|
||||
const g = grantHeroes(e, w.hero, 'package', { tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0, usd: heroOrderPrice(c, w.hero) / 100, packageUsd: cents / 100 }, (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()));
|
||||
@@ -569,7 +596,7 @@ function tierStats(t) {
|
||||
if (b.ts >= d30 && rows.some(x => x !== b && rowTier(x) === k && x.ts < b.ts)) o.renewals30d += 1;
|
||||
}
|
||||
}
|
||||
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero') out[tierOk(o.tier) ? o.tier : 'weekly'].waitingOrders += 1;
|
||||
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero' && o.kind !== 'stackpro') out[tierOk(o.tier) ? o.tier : 'weekly'].waitingOrders += 1;
|
||||
for (const k of TIERS) for (const f of ['usdWeek', 'usdMonth', 'usdTotal']) out[k][f] = Math.round(out[k][f] * 100) / 100;
|
||||
return out;
|
||||
}
|
||||
@@ -600,7 +627,7 @@ function adminStats(now) {
|
||||
const t = now || Date.now(); const c = cfg(); const ws = weekStart(t); const day = dayKey(t); const wkFrom = dayKey(ws);
|
||||
let active = 0, soldTotal = 0, usdTotal = 0, soldWeek = 0, usdWeek = 0, waiting = 0, comped = 0;
|
||||
for (const [, p] of passes) { if (!p) continue; if (topTier(tiersOf(p), t)) active += 1; for (const b of p.bought || []) { if (!isSale(b)) { comped += 1; continue; } soldTotal += 1; usdTotal += Number(b.usd) || 0; if (b.ts >= ws) { soldWeek += 1; usdWeek += Number(b.usd) || 0; } } }
|
||||
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero') waiting += 1;
|
||||
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero' && o.kind !== 'stackpro') waiting += 1;
|
||||
const wk = { pass: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, free: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, carried: 0, dropped: 0, deferredOut: 0, grants: 0, would: { dropped: 0, deferred: 0, hitsDaily: 0, hitsTotal: 0 }, players: 0 };
|
||||
const today = { allowed: 0, grants: 0, players: 0 };
|
||||
let qEntries = 0, qPol = 0, qMembers = 0; const byGame = {};
|
||||
@@ -645,5 +672,5 @@ function prune(now) {
|
||||
return n;
|
||||
}
|
||||
|
||||
module.exports = { init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, HERO_DEFS, HERO_KEYS, heroesOwned, heroClaim, heroView, buyHero, cancelHeroOrder, compHero, revokeHero, heroStats, flag, activity, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
|
||||
module.exports = { STACK_PRO_CENTS, stackPro, stackProView, buyStackPro, cancelStackOrder, compStackPro, stackProOwners, init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, HERO_DEFS, HERO_KEYS, heroesOwned, heroClaim, heroView, buyHero, cancelHeroOrder, compHero, revokeHero, heroStats, flag, activity, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
|
||||
_ledger: () => L };
|
||||
|
||||
+8
-1
@@ -155,6 +155,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
{ key: 'level3', label: 'Nexus', sub: 'fully qualified', img: '/badges/badge-nexus.jpg?v=2', ribbonY: 0.73 },
|
||||
{ key: 'fridays', label: 'Five Fridays', sub: 'five Five Dollar Fridays in a row', img: '/badges/badge-fridays.jpg', ribbonY: 0.719 },
|
||||
{ key: 'gamepass', label: 'Game Pass', sub: 'bought a Game Pass', img: '/badges/badge-gamepass.jpg', ribbonY: 0.84 },
|
||||
{ key: 'stackpro', label: 'Stack POL Pro', sub: 'unlocked Stack POL Pro', img: '/badges/badge-stackpro.jpg', ribbonY: 0.855 }, // 2026-11-09
|
||||
// Monthly Refuel badges (2026-10-24): final art, ribbon heights measured per image
|
||||
{ key: 'refuelStart', label: 'Engine Started', sub: 'first monthly refuel', img: '/badges/badge-refuelstart.jpg?v=2', ribbonY: 0.735, earnedOnly: true },
|
||||
{ key: 'refuel3', label: 'Refueled 3 months', sub: 'three monthly refuels in a row', img: '/badges/badge-refuel3.jpg?v=3', ribbonY: 0.783, earnedOnly: true },
|
||||
@@ -912,6 +913,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
if (name === 'campaigns') ['cTarget', 'cImage', 'cVideoUrl'].forEach(id => { if ($(id)) $(id).value = ''; }); // no residual URL between visits
|
||||
if (name === 'training') { if (/(^|&)g=leader/.test(paneQ)) loadTraining.filter = 'Leader tools'; loadTraining(); }
|
||||
if (name === 'pipeline') loadPipeline();
|
||||
if (name === 'promo') { const ps = /(^|&)s=([a-z]+)/.exec(paneQ || ''); if (ps) setPromoSub(ps[2]); }
|
||||
if (name === 'games') loadGames(paneQ);
|
||||
if (name === 'help' && window.IAPSupport) IAPSupport.help(paneQ); // help desk tickets (2026-10-16)
|
||||
document.getElementById('memberArea').classList.remove('side-open'); // close mobile drawer
|
||||
@@ -2797,7 +2799,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
function showStackPol(d) {
|
||||
$('spOn').checked = !!d.on; $('spLinkRow').hidden = !d.on; $('spUrl').textContent = d.url || ''; $('spOpen').href = d.url || '#';
|
||||
$('spNote').textContent = d.on ? (d.wallet ? 'Your page goes live within 5 minutes, then updates every 5 minutes.' : 'Link a wallet (Wallet tab) so your payouts can be added up on your page.') : '';
|
||||
const pv = d.pro || {}; $('spProOn').hidden = !pv.pro; $('spProWait').hidden = !!pv.pro || !pv.waiting; $('spProOff').hidden = !!pv.pro || !!pv.waiting;
|
||||
}
|
||||
async function stackPolPost(body) { const r = await fetch('/api/my/stackpol', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }); const d = await r.json(); if (!r.ok) throw new Error(d.error || 'Could not save that.'); return d; }
|
||||
async function loadStackPol() { try { const r = await fetch('/api/my/stackpol'); const d = await r.json(); if (!r.ok) { $('spNote').textContent = d.error || ''; return; } showStackPol(d); } catch (e) {} }
|
||||
if ($('spOn')) {
|
||||
$('spOn').addEventListener('change', async () => {
|
||||
@@ -2807,11 +2811,14 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
showStackPol(d); IAP.status(on ? 'Stack POL page switched on.' : 'Stack POL page switched off.', 'ok');
|
||||
} catch (e) { $('spOn').checked = !on; IAP.status('Could not save that. Try again.', 'bad'); }
|
||||
});
|
||||
$('spProBuy').addEventListener('click', async () => { try { const d = await stackPolPost({ pro: 'buy' }); showStackPol(d); if (d.buy && d.buy.message) IAP.status(d.buy.message, 'ok'); } catch (e) { IAP.status(e.message, 'bad'); } });
|
||||
$('spProCancel').addEventListener('click', async () => { try { showStackPol(await stackPolPost({ pro: 'cancel' })); IAP.status('Pro order cancelled.', 'ok'); } catch (e) { IAP.status(e.message, 'bad'); } });
|
||||
$('spCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('spUrl').textContent); IAP.status('Link copied.', 'ok'); } catch (e) { const r = document.createRange(); r.selectNodeContents($('spUrl')); const sel = getSelection(); sel.removeAllRanges(); sel.addRange(r); } });
|
||||
}
|
||||
document.querySelectorAll('.promo-pills [data-promo]').forEach(b =>
|
||||
b.addEventListener('click', () => setPromoSub(b.dataset.promo)));
|
||||
try { setPromoSub(localStorage.getItem('iap.promoSub') || 'posts'); } catch (e) { setPromoSub('posts'); }
|
||||
const promoDeep = /^#promo\?(?:.*&)?s=([a-z]+)/.exec(location.hash); // a deep link to one tab, e.g. stackpol.com's Pro button: /my#promo?s=stackpol (2026-11-09)
|
||||
try { setPromoSub((promoDeep && promoDeep[1]) || localStorage.getItem('iap.promoSub') || 'posts'); } catch (e) { setPromoSub('posts'); }
|
||||
async function loadInbox() {
|
||||
try {
|
||||
const r = await (await fetch('/api/my/inbox')).json();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
+8
-1
@@ -858,6 +858,13 @@
|
||||
<label style="display:flex;gap:10px;align-items:center;font-weight:700;cursor:pointer"><input type="checkbox" id="spOn"> Show my Stack POL page</label>
|
||||
<div class="promo-strip" id="spLinkRow" style="padding:12px 0 0" hidden><div><span class="eyebrow" style="margin:0 0 4px">Your page</span><div class="mono small" id="spUrl" style="overflow-wrap:anywhere"></div></div><div style="display:flex;gap:8px;flex-wrap:wrap"><button class="btn small sec" type="button" id="spCopy">Copy link</button><a class="btn small" id="spOpen" href="#" target="_blank" rel="noopener">Open</a></div></div>
|
||||
<p class="muted small" id="spNote" style="margin:10px 0 0"></p>
|
||||
<div style="margin-top:16px;padding-top:14px;border-top:1px solid var(--line)">
|
||||
<h4 style="margin:0 0 6px">⭐ Stack POL Pro</h4>
|
||||
<p class="muted small" style="margin:0 0 10px">Pro puts your own LinkSpin Banner Spins and spin links on your Stack POL page, so the people who visit it see your offers, and adds a shareable stack card. One time, yours for good: it switches on with your next ad package of $10 or more. You keep every credit of that package for your ads, and your sponsor line is paid on chain as usual.</p>
|
||||
<div id="spProOff"><button class="btn small" type="button" id="spProBuy">Get Pro with a $10+ package</button></div>
|
||||
<div id="spProWait" hidden><p class="small" style="margin:0 0 8px"><b>Waiting for your package.</b> Pro switches on the moment your next package of $10 or more settles on chain.</p><a class="btn small" href="/my?from=stackpro#buy">Buy a package</a> <button class="btn small sec" type="button" id="spProCancel">Cancel</button></div>
|
||||
<p class="small" id="spProOn" hidden style="margin:0">✅ <b>Pro is on.</b> Your LinkSpin Banner Spins and spin links show on your page within 5 minutes of any change.</p>
|
||||
</div>
|
||||
<p class="muted small" style="margin:10px 0 0">Your page shows your own results only. Nothing on it is a promise of what anyone else will earn.</p>
|
||||
</div>
|
||||
<!-- BixPay partner kit (2026-10-29): the member's resolved partner link, posts, an email swipe and four text-only banners; promo.js fillBix -->
|
||||
@@ -1285,7 +1292,7 @@
|
||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||
<script src="/assets/promo.js?v=20261103gp"></script>
|
||||
<script src="/assets/support.js?v=20261101th"></script>
|
||||
<script src="/assets/my.js?v=20261109sp"></script>
|
||||
<script src="/assets/my.js?v=20261109pro2"></script>
|
||||
<script src="/assets/fuel.js?v=20261025ff"></script>
|
||||
<script src="/assets/engine-room.js?v=20261101th"></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// Stack POL page switch + Stack POL Pro (2026-11-09), end to end against a LOCAL copy. node qa/stackpro.mjs
|
||||
// Boots server.js on its own port with a throwaway DATA_DIR (JSON store, devCode sign-in). Nothing touches production.
|
||||
// Pro is NEW MONEY only: "Get Pro" opens a waiting order; only a package of $10 or more, mined after the order, by the member's own
|
||||
// position, fulfils it; one package fulfils one order (a pass and Pro never ride the same purchase); credits never count.
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { spawn } from 'node:child_process';
|
||||
|
||||
const SITE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||
const PORT = Number(process.env.SP_PORT || 8803);
|
||||
const B = 'http://127.0.0.1:' + PORT;
|
||||
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-stackpro-')); fs.mkdirSync(path.join(DATA, 'uploads'));
|
||||
let fails = 0; const ok = (cond, label, extra) => { console.log((cond ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!cond) fails++; };
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
const srv = spawn(process.execPath, ['server.js'], { cwd: SITE, stdio: ['ignore', 'pipe', 'pipe'],
|
||||
env: Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: 'localtest', DEV_POL_USD: '0.10' }) });
|
||||
let log = ''; srv.stdout.on('data', d => log += d); srv.stderr.on('data', d => log += d);
|
||||
async function api(p, o, headers) {
|
||||
const opts = { method: (o && 'data' in o) ? 'POST' : 'GET', headers: Object.assign({ 'Content-Type': 'application/json' }, headers || {}) };
|
||||
if (o && 'data' in o) opts.body = JSON.stringify(o.data);
|
||||
const r = await fetch(B + p, opts); let j = null; try { j = await r.json(); } catch (e) {} return { status: r.status, j };
|
||||
}
|
||||
async function signIn(email, username) {
|
||||
const s = await api('/api/auth/email/start', { data: { email, fts: Date.now() - 5000 } });
|
||||
const v = await fetch(B + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, code: s.j && s.j.devCode }) });
|
||||
const cookie = (v.headers.getSetCookie ? v.headers.getSetCookie() : [v.headers.get('set-cookie')]).map(c => String(c).split(';')[0]).join('; ');
|
||||
if (username) await api('/api/my/profile', { data: { username } }, { Cookie: cookie });
|
||||
return { Cookie: cookie };
|
||||
}
|
||||
const buy = (email, cents, extra) => api('/api/dev/gamepass-purchase', { data: Object.assign({ email, cents }, extra || {}) });
|
||||
const optin = () => { try { return JSON.parse(fs.readFileSync(path.join(DATA, 'stack-optin.json'), 'utf8')); } catch (e) { return {}; } };
|
||||
try {
|
||||
for (let i = 0; i < 40; i++) { try { if ((await fetch(B + '/api/config')).ok) break; } catch (e) {} await sleep(500); }
|
||||
const A = 'sp-a@example.com', Bm = 'sp-b@example.com';
|
||||
ok((await api('/api/my/stackpol')).status === 401, 'signed out: 401');
|
||||
const ha = await signIn(A, 'stacka'), hb = await signIn(Bm, 'stackb');
|
||||
let r = await api('/api/my/stackpol', null, ha); ok(r.status === 200 && r.j.on === false && r.j.url === 'https://stackpol.com/stacka' && r.j.pro && r.j.pro.pro === false, 'GET: off by default, url, not pro', JSON.stringify(r.j));
|
||||
r = await api('/api/my/stackpol', { data: { on: true } }, ha); ok(r.j.on === true && optin().users.stacka === true, 'switch on writes stack-optin.json');
|
||||
r = await api('/api/my/stackpol', { data: { on: false } }, ha); ok(r.j.on === false && optin().users.stacka === false, 'switch off');
|
||||
// a package with no Pro order unlocks nothing
|
||||
await buy(A, 1000); r = await api('/api/my/stackpol', null, ha); ok(r.j.pro.pro === false, 'a $10 package without a Pro order does not unlock Pro');
|
||||
// Get Pro opens a waiting order
|
||||
r = await api('/api/my/stackpol', { data: { pro: 'buy' } }, ha); ok(r.j.buy && r.j.buy.needPay === true && r.j.pro.waiting === true && r.j.buy.usd === 10, 'Get Pro opens a waiting order ($10)', JSON.stringify(r.j.buy));
|
||||
const orderTs = r.j.buy.orderTs;
|
||||
r = await api('/api/my/stackpol', { data: { pro: 'buy' } }, ha); ok(r.j.buy.reused === true, 'Get Pro twice reuses the same order');
|
||||
await buy(A, 500); r = await api('/api/my/stackpol', null, ha); ok(r.j.pro.pro === false && r.j.pro.waiting === true, 'a $5 package does not fulfil Pro');
|
||||
await buy(A, 2000, { minedAt: orderTs - 60000 }); r = await api('/api/my/stackpol', null, ha); ok(r.j.pro.pro === false, 'a package mined BEFORE the order does not fulfil Pro');
|
||||
const fx = await buy(A, 1000); r = await api('/api/my/stackpol', null, ha); ok(fx.j.order && fx.j.order.stackPro === true && r.j.pro.pro === true && r.j.pro.waiting === false, 'a $10 package after the order unlocks Pro', JSON.stringify(fx.j));
|
||||
ok(optin().pro && optin().pro.stacka === true, 'Pro owner lands in stack-optin.json for the indexer');
|
||||
const tx = '0x' + 'ab'.repeat(32);
|
||||
// one package fulfils ONE order: B opens a pass AND a Pro order, a single $20 package unlocks only one (the higher price: Pro)
|
||||
await api('/api/my/stackpol', { data: { pro: 'buy' } }, hb);
|
||||
const gp = await api('/api/my/gamepass/buy', { data: {} }, hb); const gpw = await api('/api/my/gamepass', null, hb); ok(gpw.j.waiting === true || !gpw.j.enabled, 'B: a Game Pass order is waiting too (or passes are off locally)', JSON.stringify(gp.j).slice(0, 120));
|
||||
await buy(Bm, 2000, { tx }); r = await api('/api/my/stackpol', null, hb);
|
||||
const st = await api('/api/my/gamepass', null, hb);
|
||||
ok(r.j.pro.pro === true, 'B: the $20 package unlocked Pro (the higher-priced order)');
|
||||
ok(st.j.active === false && (st.j.waiting === true || !gpw.j.waiting), 'B: the same package did NOT also start a Game Pass (still waiting)', 'active=' + st.j.active + ' waiting=' + st.j.waiting);
|
||||
await buy(Bm, 2000, { tx }); const st2 = await api('/api/my/gamepass', null, hb); ok(st2.j.active === false, 'replaying the same tx fulfils nothing');
|
||||
r = await api('/api/my/stackpol', { data: { pro: 'cancel' } }, ha); ok(r.status === 200 && r.j.pro.pro === true, 'cancel after paying keeps Pro');
|
||||
} catch (e) { console.log('FAIL exception', e && e.stack || e); fails++; }
|
||||
finally { try { srv.kill(); } catch (e) {} try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
|
||||
if (fails) console.log(log.split('\n').filter(l => /stack|gamepass|error/i.test(l)).slice(-15).join('\n'));
|
||||
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exit(fails ? 1 : 0);
|
||||
@@ -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