Admin: grant Stack POL Pro for a $10+ package bought without a Pro order first (Marty 2026-11-09, Orlando). POST /api/admin/stackpro/grant {memberId, tx}: the tx must be an on-chain Purchase of $10+ by that member; recorded as a package sale with its tx, marks the Stack POL page Pro and posts the badge once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-09 16:30:34 -06:00
parent 054ce10985
commit 1da37f05ab
2 changed files with 23 additions and 1 deletions
+13
View File
@@ -4530,6 +4530,19 @@ const server = http.createServer(async (req, res) => {
if (!r.error) console.log('bonus heroes admin test', p.split('/').pop(), hero, me);
return json(res, r.error ? 400 : 200, Object.assign({ email: me, test: true, heroes: gamepass.heroView(me, Date.now(), { preview: true }) }, r));
}
// Admin: give Stack POL Pro for a package that was bought without a Pro order first (Marty 2026-11-09). The tx must be an on-chain
// Purchase of $10 or more by that member id; then the badge posts like any unlock.
if (p === '/api/admin/stackpro/grant' && req.method === 'POST') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const b = await readBody(req); const id = Number(b.memberId), tx = String(b.tx || '').toLowerCase();
let ev = null; try { ev = (JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'chain-index.json'), 'utf8')).events || []).find(e => e.type === 'Purchase' && String(e.tx || '').toLowerCase() === tx); } catch (e) {}
if (!ev || Number(ev.buyerId) !== id || Number(ev.priceCents) < gamepass.STACK_PRO_CENTS) return json(res, 400, { error: 'That tx is not a $10+ package bought by member #' + id + '.', ev });
const a = await accounts.byMemberId(id); if (!a || !a.email) return json(res, 404, { error: 'No account for member #' + id });
const r = gamepass.grantStackProForPackage(a.email, tx, Number(ev.priceCents), id, b.note);
try { await stackProMark(a.email); } catch (e) {}
let posted = 0; try { posted = await postBadgeOnce(a.email, 'stackpro'); } catch (e) { console.error('stackpro badge', e.message); }
return json(res, 200, Object.assign({ username: a.username, posted }, r));
}
if (p === '/api/admin/heroes/stats' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, gamepass.heroStats()); }
// Admin > Game Pass tier test (2026-10-25, Marty): every tier as members will see it, with the admin's OWN account's state, and a
// test buy of a tier that is not on sale yet (opens the same waiting order a member gets; a fresh package on /my fulfils it).