Help desk: support tickets for members (Help pane), the public /support page with private ticket links, chatbot hand-off, and an admin Support pane

- tickets.js: one shared desk (platform iap now, linkspin later), dual-mode store (MySQL tables tickets + ticket_messages, else support.json); refs IAP-<1000+id> / LS-; private no-login link /support/t/<ref>.<HMAC> signed with DATA_DIR/support.key (or SUPPORT_SECRET); ingestEmail() ready for the support@ intake step (threads by Message-ID, then [ref] in the subject from the same sender)
- Member Help pane (/my#help): list with status + unread badge, new ticket (category, subject, message, up to 2 screenshots via /api/my/upload), thread + reply (a reply reopens a closed ticket)
- Public /support: name, email, category, subject, message behind the sign-up walls (honeypot, form age, per-IP limits with the icon check, global cap) plus a per-email cap; confirmation email with the ref and the private link
- Chatbot: CANNED + systemPrompt know the help desk; answers that cannot help (or "talk to a human") offer "Send this to support", which files the last turns as a ticket (members: Help pane; signed out: email + the same guard)
- Admin Support pane: open / waiting / closed / all, platform, category, search; open-count badge; ticket view with requester account info, internal notes, status/priority/category, saved replies (site setting supportTemplates); deep link /admin#support?t=<ref>
- Notifications: new ticket / member reply -> Telegram to Marty's private chat only (supportTelegramChat, default 1289244227, site bot then Hermes fallback, never a group or the Discord relay) + email to ADMIN_EMAIL, max one per ticket per 10 min; Marty's reply -> email "[IAP-1042] subject" + a 'notice' inbox message for members, bursts batched
- support* settings are kept out of /api/config; Support link in the site footer, home footer, member page foot, terms and privacy; "Contact support" errors point at /support
- QA walk: member Help ticket flow, admin Support pane + deep link, internal-note leak check, public /support + private link + tampered token + form-age refusal
- Cache tags: common.js 20261016a, chat.js 20261016a, my.js 20261016r, admin.js 20261016sp, support.js 20261016a

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-16 16:51:30 -05:00
parent f0c868ef23
commit 9be58bd5ef
35 changed files with 1078 additions and 59 deletions
+158 -7
View File
@@ -59,9 +59,10 @@ const fridaybank = require('./fridaybank'); // Friday Bonus Hunts: days banked S
const refill = require('./refill');
const pdsync = require('./pdsync'); // PassiveDrip PTC bridge: our visit campaigns on their paid-to-click page (2026-09-30) // campaign running-low / ran-out notices, and what came of them // Five Dollar Friday: +20% credits on Friday packs, the wave, the badge (Marty, 2026-09-20)
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
const tickets = require('./tickets'); // help desk: member Help pane, public /support, chatbot hand-off, admin Support pane (Marty, 2026-10-16)
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/earning', '/games', '/blog', '/whats-new', '/leaderboard', '/friday', '/wednesday', '/presentation']);
const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/earning', '/games', '/blog', '/whats-new', '/leaderboard', '/friday', '/wednesday', '/presentation', '/support']);
let tankWaitCache = null; // dashboard: who is waiting for a sponsor (refreshed every minute)
const geo = require('./geo'); // viewer country -> tier (DB-IP lite), for campaign targeting
const burner = require('./burner'); // automatic on-chain credit burns (inert without ENGINE_KEY)
@@ -530,6 +531,7 @@ async function boot() {
// follow-up email sequence: send whatever came due (every 10 min, first pass shortly after boot)
coach.init({ dataDir: DATA_DIR, chain, accounts, mailer, ads, tank, lb: () => leaderboard, siteConfig });
pipeline.init({ dataDir: DATA_DIR, accounts, coach, chain });
tickets.init({ dataDir: DATA_DIR, mailer, messages, accounts, adminEmail: ADMIN_EMAIL, telegram: supportTelegram });
badge.init({ publicDir: PUBLIC_DIR });
gamestats.init({ dataDir: DATA_DIR });
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, publicDir: PUBLIC_DIR, games: gamestats, launchesToday: () => GAMES().filter(g => (g.soon && g.soon.opens === todayCT()) || (g.season && g.season.start === todayCT())).map(g => g.name),
@@ -703,6 +705,8 @@ function siteConfig() {
geoTier2: '', // empty = built-in default (rest of Western/Central Europe, JP, KR, SG, HK, TW, IL, Gulf, ZA, BR, MX, AR, CL, CO ...); tier 3 = everything else
// Game Pass (2026-10-16, docs/GAME-PASS.md): off until Marty flips it; caps apply from capsStartDate (Central), before it polgrant allows everything and only records
gamePassEnabled: '0', gamePassPriceCredits: 500, gamePassDays: 7, capFreeDaily: 0.30, capFreeTotal: 2.0, capPassDaily: 1.50, capPassTotal: 5.0, capsStartDate: '', passTournamentPct: 5,
supportTelegramChat: '1289244227', // help desk pings: Marty's PRIVATE chat only (a positive user id; group/channel ids are refused). Sent with telegramBotToken, Hermes bot as fallback
supportTemplates: '', // help desk saved replies, JSON [{name, body}] (Admin > Support > Saved replies); empty = the built-in set
telegramGamesChatId: '', telegramGamesTopicId: '661565', // Game Achievements topic for the weekly Pass Tournament post (chat blank = the shared echo chat)
pnlFixedMonthlyUsd: 0
}, saved);
@@ -990,6 +994,55 @@ function tgSendAs(token, chatId, text, threadId) {
rq.end(body);
});
}
// Help desk pings (2026-10-16): Marty's PRIVATE Telegram chat only, never a group, topic or feed. tgSendAs skips the
// Discord relay entirely. Site bot (telegramBotToken) first, Marty's Hermes bot if that one cannot reach him.
async function supportTelegram(text) {
const sc = siteConfig();
const chat = String(sc.supportTelegramChat || '1289244227').trim();
if (!/^\d{4,15}$/.test(chat)) { console.error('support ping refused: supportTelegramChat must be a private chat id (positive number), not', chat); return false; }
let ok = false;
const site = String(sc.telegramBotToken || '').trim(), hermes = String(process.env.HERMES_BOT_TOKEN || '').trim();
if (site) ok = await tgSendAs(site, chat, text);
if (!ok && hermes) ok = await tgSendAs(hermes, chat, text);
if (!ok) console.error('support ping not delivered (chat ' + chat + ', site bot ' + (site ? 'set' : 'missing') + ', hermes ' + (hermes ? 'set' : 'missing') + ')');
return ok;
}
// Public support form + signed-out chatbot hand-off: the sign-up guard's walls (honeypot, form age, per-IP limits with the
// icon check once tripped, a global cap) plus a hard per-email cap. Returns null to allow, or { status, body }.
const SUPPORT_LIMITS = { ipHour: 5, ipDay: 15, emailHour: 3, emailDay: 8, globalPerMin: 20, minFormMs: 2000 };
const supportHits = new Map(); // 'ip:<ip>' | 'em:<email>' | 'tk:<ticket id>' -> [timestamps, 24h]
const supportChal = new Map(); // ip -> { chal, passUntil }
const supportGlobal = { minute: 0, n: 0 };
const supportRecent = (k, ms) => { const now = Date.now(); const t = (supportHits.get(k) || []).filter(ts => now - ts < 86400000); supportHits.set(k, t); return t.filter(ts => now - ts < ms).length; };
const supportMark = k => { const t = supportHits.get(k) || []; t.push(Date.now()); supportHits.set(k, t); if (supportHits.size > 5000) for (const [kk, v] of supportHits) if (!v.length || Date.now() - v[v.length - 1] > 86400000) supportHits.delete(kk); };
const supportFlood = (k, n, ms) => { if (supportRecent(k, ms) >= n) return true; supportMark(k); return false; }; // signed-in and private-link replies: a plain cap
function supportGuard(req, b, email) {
const now = Date.now();
const hpRaw = String(b.hp_field_x9 || '').trim();
const hp = !!hpRaw && hpRaw.toLowerCase() !== email; // own email = phone autofill, not a bot
const fts = Number(b.fts) || 0;
const fage = (b.fage !== undefined && b.fage !== null && b.fage !== '' && Number.isFinite(Number(b.fage))) ? Number(b.fage) : (fts ? now - fts : -1);
if (fage < SUPPORT_LIMITS.minFormMs) { guardLog(req, 'support form-age', b); return { status: 400, body: { error: 'Give the page a few seconds, then send again.' } }; }
if (fage > 12 * 3600 * 1000) { guardLog(req, 'support form-stale', b); return { status: 400, body: { error: 'This page has been open a long time. Refresh it, then send again.' } }; }
const minute = Math.floor(now / 60000);
if (supportGlobal.minute !== minute) { supportGlobal.minute = minute; supportGlobal.n = 0; }
if (supportGlobal.n >= SUPPORT_LIMITS.globalPerMin) { guardLog(req, 'support global-limit', b); return { status: 429, body: { error: 'Busy right now. Try again in a minute.' } }; }
if (supportRecent('em:' + email, 3600000) >= SUPPORT_LIMITS.emailHour || supportRecent('em:' + email, 86400000) >= SUPPORT_LIMITS.emailDay) {
guardLog(req, 'support email-limit', b);
return { status: 429, body: { error: 'You have sent several tickets already. Reply on the one you have open (the link is in your confirmation email) and Marty will see it there.' } };
}
const ip = clientIp(req);
const limited = hp || supportRecent('ip:' + ip, 3600000) >= SUPPORT_LIMITS.ipHour || supportRecent('ip:' + ip, 86400000) >= SUPPORT_LIMITS.ipDay;
const rec = supportChal.get(ip) || { chal: null, passUntil: 0 };
if (limited && now >= rec.passUntil) {
const pick = String(b.pick || '');
if (pick && rec.chal && rec.chal.exp > now && pick === rec.chal.answer) { rec.passUntil = now + CODE_LIMITS.passMs; rec.chal = null; }
else { guardLog(req, pick ? 'support wrong-pick' : hp ? 'support honeypot-challenge' : 'support ip-limit', b); const challenge = codeChallenge(rec); supportChal.set(ip, rec); if (supportChal.size > 5000) supportChal.clear(); return { status: 429, body: { error: pick ? 'That was not it. Try once more.' : 'Quick check before we send it.', challenge } }; }
supportChal.set(ip, rec);
}
supportGlobal.n += 1; supportMark('ip:' + ip); supportMark('em:' + email);
return null;
}
function fraudAlert(email, fc, spAcct, blocked) {
try {
const sc = siteConfig();
@@ -1911,7 +1964,7 @@ const server = http.createServer(async (req, res) => {
const c = chain.getConfig();
// public copy of the site settings: never anything that looks like a credential
const pubSite = {};
for (const [k, v] of Object.entries(siteConfig())) if (!/secret|token|password|private|apikey|api_key/i.test(k)) pubSite[k] = v;
for (const [k, v] of Object.entries(siteConfig())) if (!/secret|token|password|private|apikey|api_key/i.test(k) && !/^support/.test(k)) pubSite[k] = v; // support* = help desk internals (Marty's chat id, saved replies)
return json(res, 200, Object.assign({ contract: c.contract, chainId: c.chainId,
chainName: c.chainName, explorer: c.explorer, rpc: c.rpcs[0],
emailAuth: mailer.hasKey() || !IS_PROD }, pubSite));
@@ -2043,6 +2096,48 @@ const server = http.createServer(async (req, res) => {
return json(res, r.error ? 400 : 200, r);
}
// -- help desk, public side (2026-10-16, tickets.js): /support form, the private no-login ticket link, the chatbot hand-off
if (p === '/api/support' && req.method === 'POST') {
const b = await readBody(req);
const s = await auth.fromRequest(req);
const acct = s && s.email ? await accounts.byEmail(s.email) : null; // signed in: the ticket is theirs, whatever was typed
const email = acct ? acct.email : String(b.email || '').trim().toLowerCase();
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) return json(res, 400, { error: 'That email address does not look right.' });
const guard = supportGuard(req, b, email);
if (guard) return json(res, guard.status, guard.body);
const r = await tickets.create({ source: 'public', email, name: b.name || (acct && acct.username) || '', username: acct && acct.username, subject: b.subject, category: b.category, body: b.body });
if (r.error) return json(res, 400, r);
return json(res, 200, { ok: true, ref: r.ticket.ref, token: r.token, member: !!acct });
}
m = /^\/api\/support\/t\/([A-Za-z0-9_.-]{20,80})(\/reply)?$/.exec(p);
if (m && (req.method === 'GET' || (m[2] && req.method === 'POST'))) {
const t = await tickets.byToken(m[1]);
if (!t) return json(res, 404, { error: 'This ticket link is not valid. Open the newest email about your ticket, or send a new one.' });
if (req.method === 'GET') return json(res, 200, await tickets.memberView(t));
const b = await readBody(req);
if (supportFlood('tk:' + t.id, 20, 3600000)) return json(res, 429, { error: 'That is a lot of messages in an hour. Give Marty a moment to catch up.' });
const r = await tickets.addMessage(t.id, { author: 'member', body: b.body, via: 'link' });
return json(res, r.error ? 400 : 200, r.error ? r : await tickets.memberView(r.ticket));
}
if (p === '/api/support/chatbot' && req.method === 'POST') {
const b = await readBody(req);
const s = await auth.fromRequest(req);
const acct = s && s.email ? await accounts.byEmail(s.email) : null;
const email = acct ? acct.email : String(b.email || '').trim().toLowerCase();
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email)) return json(res, 400, { error: 'Add your email so Marty can reply.', needEmail: true });
if (acct) { if (supportFlood('em:' + email, 5, 3600000)) return json(res, 429, { error: 'You have sent several tickets in the last hour. Open Help in your dashboard to add to one.' }); }
else { const guard = supportGuard(req, b, email); if (guard) return json(res, guard.status, guard.body); }
const tr = Array.isArray(b.transcript) ? b.transcript : [];
const turns = tr.slice(-8).map(x => ((x && x.who === 'me') ? 'Me: ' : 'Assistant: ') + String((x && x.text) || '').replace(/\s+/g, ' ').trim().slice(0, 600)).filter(x => x.length > 6);
const firstQ = tr.find(x => x && x.who === 'me' && String(x.text || '').trim());
const note = String(b.note || '').trim().slice(0, 2000);
const body = (note ? note + '\n\n' : '') + (turns.length ? 'From the chat assistant:\n' + turns.join('\n') : '(sent from the chat assistant)');
const r = await tickets.create({ source: 'chatbot', email, name: b.name || (acct && acct.username) || '', username: acct && acct.username, category: 'Other',
subject: 'Chat: ' + (firstQ ? String(firstQ.text).replace(/\s+/g, ' ').trim().slice(0, 100) : 'question for support'), body });
if (r.error) return json(res, 400, r);
return json(res, 200, { ok: true, ref: r.ticket.ref, member: !!acct, link: acct ? '/my#help?t=' + r.ticket.ref : '/support/t/' + r.token });
}
// -- accounts: email + password is the normal join path (wallet comes
// out only at purchase / payout-activation time and gets linked then)
if (p === '/api/signup' && req.method === 'POST') {
@@ -2108,7 +2203,7 @@ const server = http.createServer(async (req, res) => {
const via = parseCookies(req)['iap.angle'] || (pend && pend.via) || '';
const joinedRef = decodeURIComponent(parseCookies(req)['iap.ref'] || '') || (pend && pend.joinedRef) || null;
if (ref && !parseCookies(req)['iap.sponsor']) console.log('sponsor recovered without cookie', e.replace(/^(.).*(@.*)$/, '$1***$2'), 'ref', ref, pageTok(b.ref) ? '(page token)' : '(remembered from the code request)');
if (fraud.isSuspended(e)) return json(res, 403, { error: 'This account is suspended. Contact support.' });
if (fraud.isSuspended(e)) return json(res, 403, { error: 'This account is suspended. Contact support at instantadpay.com/support.' });
let fraudFlags = [];
const existing = await accounts.byEmail(e);
const claim = accounts.isUnclaimedShell(existing); // a waiting LinkSpin account: this sign-in is its owner's real sign-up
@@ -2198,7 +2293,7 @@ const server = http.createServer(async (req, res) => {
if (rec.tries > 6) { emailCodes.delete(e); return json(res, 400, { error: 'Too many tries. Request a fresh code.' }, cors); }
if (String(b.code || '').trim() !== rec.code) return json(res, 400, { error: 'That code does not match.' }, cors);
emailCodes.delete(e);
if (fraud.isSuspended(e)) return json(res, 403, { error: 'This account is suspended. Contact support.' }, cors);
if (fraud.isSuspended(e)) return json(res, 403, { error: 'This account is suspended. Contact support at instantadpay.com/support.' }, cors);
const pend = pendingSponsor.get(e);
const ref = pageTok(b.ref) || (pend && pend.ref) || '';
const via = String(b.game); const srcTag = String(b.src || '').toLowerCase().replace(/[^a-z0-9_.-]/g, '').slice(0, 30);
@@ -2812,7 +2907,7 @@ const server = http.createServer(async (req, res) => {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
const b = await readBody(req);
if (fraud.excluded(s.email)) return json(res, 403, { error: 'Adoptions are not available on this account. Contact support.' });
if (fraud.excluded(s.email)) return json(res, 403, { error: 'Adoptions are not available on this account. Contact support at instantadpay.com/support.' });
const r = await tank.adopt(s.email, b.who, b.note);
if (r.ok) { // tell the payments topic who picked whom up (Marty, 2026-09-12)
pushFeed({ type: 'Adopted', sponsor: r.adopterName, member: r.adopteeName, ts: Date.now() });
@@ -2959,7 +3054,7 @@ const server = http.createServer(async (req, res) => {
// a username is permanent once set: the invite link, the public wall and every
// banner already printed carry it (Marty, 2026-09-10)
if (before && before.username && String(b.username || '').trim().toLowerCase() !== String(before.username).toLowerCase())
return json(res, 400, { error: 'Your username is locked. Your invite link, your public page and any banners you shared all carry @' + before.username + '. Contact support if it truly has to change.' });
return json(res, 400, { error: 'Your username is locked. Your invite link, your public page and any banners you shared all carry @' + before.username + '. Contact support (instantadpay.com/support) if it truly has to change.' });
const r = await accounts.setUsername(s.email, b.username);
// First time a username is set (onboarding): now there's a real name to
// show, so notify the sponsor here rather than at signup (where it'd just
@@ -3794,6 +3889,29 @@ const server = http.createServer(async (req, res) => {
}
return json(res, 200, { ok: true, sent: recipients.length });
}
// -- help desk, member side (2026-10-16): the Help pane lists, opens and answers this member's tickets
if (p === '/api/my/support' && (req.method === 'GET' || req.method === 'POST')) {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
if (req.method === 'GET') return json(res, 200, { tickets: await tickets.memberList(s.email), unread: await tickets.memberUnread(s.email), categories: tickets.CATEGORIES });
const b = await readBody(req);
if (supportFlood('em:' + String(s.email).toLowerCase(), 5, 3600000)) return json(res, 429, { error: 'You have opened several tickets in the last hour. Add to one of those instead.' });
const a = await accounts.byEmail(s.email);
const r = await tickets.create({ source: 'form', email: s.email, name: (a && a.username) || '', username: a && a.username, subject: b.subject, category: b.category, body: b.body, attachments: b.attachments });
return json(res, r.error ? 400 : 200, r.error ? r : { ok: true, ref: r.ticket.ref });
}
m = /^\/api\/my\/support\/((?:IAP|LS)-\d{4,9})(\/reply)?$/.exec(p);
if (m && (req.method === 'GET' || (m[2] && req.method === 'POST'))) {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
const t = await tickets.byRef(m[1]);
if (!t || t.email !== String(s.email).toLowerCase()) return json(res, 404, { error: 'Ticket not found.' });
if (req.method === 'GET') return json(res, 200, await tickets.memberView(t));
const b = await readBody(req);
if (supportFlood('tk:' + t.id, 20, 3600000)) return json(res, 429, { error: 'That is a lot of messages in an hour. Give Marty a moment to catch up.' });
const r = await tickets.addMessage(t.id, { author: 'member', body: b.body, attachments: b.attachments });
return json(res, r.error ? 400 : 200, r.error ? r : await tickets.memberView(r.ticket));
}
// -- sponsor messages: this member's inbox from their upline
if (p === '/api/my/messages' && req.method === 'GET') {
const s = await auth.fromRequest(req);
@@ -4421,6 +4539,38 @@ const server = http.createServer(async (req, res) => {
if (!isAdmin(req)) return json(res, 200, { admin: false });
return json(res, 200, { admin: true, email: ADMIN_EMAIL });
}
// -- help desk, admin side (2026-10-16): the Support pane
if (p === '/api/admin/support' && req.method === 'GET') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
return json(res, 200, Object.assign(await tickets.adminList({ status: u.searchParams.get('status'), platform: u.searchParams.get('platform'), category: u.searchParams.get('category'), q: u.searchParams.get('q') }),
{ categories: tickets.CATEGORIES, platforms: tickets.PLATFORMS }));
}
if (p === '/api/admin/support/counts' && req.method === 'GET') {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
return json(res, 200, await tickets.counts());
}
if (p === '/api/admin/support/templates' && (req.method === 'GET' || req.method === 'PUT')) {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const read = () => { const v = siteConfig().supportTemplates; let a = v; if (typeof v === 'string') { try { a = JSON.parse(v); } catch (e) { a = null; } } return Array.isArray(a) && a.length ? a : tickets.DEFAULT_TEMPLATES; };
if (req.method === 'GET') return json(res, 200, { templates: read() });
const b = await readBody(req);
const list = (Array.isArray(b.templates) ? b.templates : []).map(t => ({ name: String((t && t.name) || '').trim().slice(0, 60), body: String((t && t.body) || '').trim().slice(0, 3000) })).filter(t => t.name && t.body).slice(0, 30);
const cur = siteConfig(); cur.supportTemplates = list; fs.writeFileSync(SITE_FILE, JSON.stringify(cur, null, 2));
return json(res, 200, { ok: true, templates: read() });
}
m = /^\/api\/admin\/support\/((?:IAP|LS)-\d{4,9})(\/reply)?$/.exec(p);
if (m) {
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
const t = await tickets.byRef(m[1]);
if (!t) return json(res, 404, { error: 'Ticket not found.' });
if (m[2] && req.method === 'POST') { const b = await readBody(req); const r = await tickets.addMessage(t.id, { author: 'admin', body: b.body, internal: !!b.internal, status: b.status, attachments: b.attachments }); if (r.error) return json(res, 400, r); }
else if (!m[2] && req.method === 'PATCH') { const r = await tickets.setFields(t.id, await readBody(req)); if (r.error) return json(res, 400, r); }
else if (m[2] || req.method !== 'GET') return json(res, 405, { error: 'method' });
const v = await tickets.adminView(t.id);
const a = await accounts.byEmail(v.ticket.email);
v.requester = a ? { member: true, email: a.email, username: a.username || '', memberId: a.memberId || 0, wallet: !!a.address, created: a.created || 0, lastSeen: a.lastSeen || 0 } : { member: false, email: v.ticket.email };
return json(res, 200, v);
}
if (p === '/api/admin/refill' && req.method === 'GET') { // who was told their ads ran out, and what they did next
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
return json(res, 200, refill.stats());
@@ -4842,7 +4992,7 @@ const server = http.createServer(async (req, res) => {
+ '<style>.bp{max-width:560px;text-align:center;padding:40px 16px 60px}.bp img{width:100%;max-width:520px;border-radius:18px;border:1px solid var(--line);box-shadow:0 20px 60px rgba(0,0,0,.45)}.bp h1{font-size:clamp(24px,5vw,34px);margin:22px 0 8px}.bp p{color:var(--muted);max-width:44ch;margin:0 auto 20px}</style></head>'
+ '<body><div class="wrap bp"><img src="' + img + '" alt="' + esc(label) + ' badge for @' + esc(un) + '"><h1>@' + esc(un) + ' unlocked <em>' + label + '</em></h1><p>' + esc(sub.charAt(0).toUpperCase() + sub.slice(1)) + '. On InstantAdPay every ad package that sells pays the sponsor in the same transaction, straight to their wallet, on-chain.</p>'
+ '<a class="btn" href="/join/' + esc(un) + '">Join @' + esc(un) + '\u2019s line free</a><p class="small" style="margin-top:26px">Advertising with a performance referral program. Not an investment; no income is guaranteed.</p></div>'
+ '<script src="/assets/common.js?v=20261015a"></script><script src="/assets/blog-page.js?v=20260921a"></script></body></html>';
+ '<script src="/assets/common.js?v=20261016a"></script><script src="/assets/blog-page.js?v=20260921a"></script></body></html>';
res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'public, max-age=300' }));
return res.end(html);
}
@@ -4872,6 +5022,7 @@ const server = http.createServer(async (req, res) => {
return res.end(blog.renderPost(post, related));
}
if (p === '/wallets') return sendFile(res, path.join(PUBLIC_DIR, 'wallets.html'));
if (p === '/support' || /^\/support\/t\/[A-Za-z0-9_.-]{20,80}$/.test(p)) return sendFile(res, path.join(PUBLIC_DIR, 'support.html')); // help desk (2026-10-16): the form, and the private ticket link
if (p === '/friday') return sendFile(res, path.join(PUBLIC_DIR, 'friday.html'));
if (p === '/wednesday') return sendFile(res, path.join(PUBLIC_DIR, 'wednesday.html'));
if (p === '/refuel') return sendFile(res, path.join(PUBLIC_DIR, 'refuel.html')); // Drip Runner refuel visit (2026-09-30)