Support: Help screen, public /support page, ticket link and chat hand-off on InstantAdPay's shared desk

helpdesk.js proxies to InstantAdPay's partner API (/api/partner/support/*), signed with the
same LS_SYNC_SECRET + X-LS-Ts/X-LS-Sig as iapsync.js, IAP_URL as the base. No tickets are
stored here.

- /help: Control Room screen (list, new ticket with the desk's categories, thread, reply);
  Help on the rail with an unread badge when Marty has replied (/api/my/support/unread, 60 s cache)
- /support and /support/t/<token>: public form + private ticket link, behind the sign-up
  guard's walls (honeypot, form age, IP/email limits, icon check) on their own counters;
  these pages, their API and their files pass the curtain for anonymous visitors
- chat bubble: "Send this to support" hand-off, greeting points to Help and /support;
  chatbot flags hand-off on support questions and unsure answers; CANNED + FACTS updated,
  KNOWLEDGE_DATE 2026-10-16
- Support in the home nav, common.js nav/footer and every public footer; copy that said
  "message support" now points at Help
- cache tags bumped (common.js, cr-shell.js, chat.js, my.js, credits-screen.js)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-16 18:05:02 -05:00
parent 3ac8cf3cd0
commit df1b900f45
38 changed files with 580 additions and 44 deletions
+14 -6
View File
@@ -16,7 +16,7 @@ let DATA_DIR = null;
let chain = null;
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
const CONTRACT = '0x26Bdc556b94399bEdd69ae3ACA5aA6c54D946e8b';
const KNOWLEDGE_DATE = '2026-10-12'; // the day the CANNED answers and FACTS below were last checked against the site
const KNOWLEDGE_DATE = '2026-10-16'; // the day the CANNED answers and FACTS below were last checked against the site
function init(opts) { DATA_DIR = opts.dataDir; chain = opts.chain; }
function key() {
@@ -26,7 +26,11 @@ function key() {
function enabled() { return !!key(); }
// ---- canned answers: instant, free, always in voice. Order matters: the first regex that matches wins. ----
// handoff: true makes the widget offer "Send this to support" under the answer (help desk, 2026-10-16)
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 linkspin|someone|a (human|person|real person))|support (email|address|ticket|team|desk|page)|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 = [
{ re: SUPPORT_RE, handoff: true,
a: 'Open Help in your Control Room (' + SITE_URL + '/help) to send Marty a ticket, and his replies land right there and in your email. Not signed in or locked out? Use ' + SITE_URL + '/support. You can also tap "Send this to support" below and I will pass this chat along.' },
{ re: /(instant ?ad ?pay|[^a-z]iap[^a-z]|differen|same as|another (site|program|property)|why (two|another)|sister (site|property)|which (one|site) (should|do))/i,
a: 'InstantAdPay is the ad marketplace: you buy ad packages there, earn credits by viewing ads, and get paid when your line buys. LinkSpin is the tool side of the same network: a link rotator, a page builder and ad zones for your own sites, free with an email address. Its packages buy ad delivery across the LinkSpin viewer, every member zone and the partner network, and they pay your sponsor line the same way, inside the purchase transaction. Same people above and below you, same wallet, and your InstantAdPay username and profile carry over when you sign in with the same email.' },
{ re: /(pyramid|ponzi|scam|scheme|mlm|legit)/i,
@@ -96,13 +100,15 @@ FACTS:
- ACCOUNT: join at ${SITE_URL}/join with email only, a six-digit code, no password. Wallet linking happens inside the Control Room (Credits screen): one signature to link, then payouts switch on by activating (one transaction, gas only) or by buying any package. SafePal is the recommended wallet; MetaMask, Phantom (turn Polygon on first) and any WalletConnect wallet work; Trust Wallet blocks a buy that spends most of its POL. MoonPay card on-ramp from the Credits screen puts POL on Polygon into the member's own wallet.
- SPONSOR: the invite link opened most recently sets the sponsor (30-day cookie), shown on the join page, locked when the account is created; the contract binds the buyer to that sponsor at the first purchase. CARRY-OVER: Crypto Team Build Network members who sign in with the email they use on InstantAdPay get their InstantAdPay sponsor from the network registry automatically when no invite link was used. Wrong sponsor before the first purchase: the admin can move the account. Members should switch on payouts before their people buy.
- CONTROL ROOM screens: Links, Pages, Zones (with Audiences), Ads, Credits, Reports, Team (three levels, who has payouts on, who bought, qualifying-buyer counts), Wallet (what was paid to this wallet, payout history). More at ${SITE_URL}/tools: Promo tools, Training, Pipeline (a follow-up board for prospects and directs), My line (including the holding tank: members who joined with no sponsor wait there and can be adopted by a member with payouts on and their own qualifying package), Profile.
- SUPPORT (LIVE 2026-10-16): members open Help in the Control Room (${SITE_URL}/help) to send Marty a ticket (pick a category, a subject, the message), see each ticket's status (Open, Waiting on you, Closed), and read and answer his replies; a badge on the Help item shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at ${SITE_URL}/support, gets a private link to follow the ticket without signing in, and can reply there. The chat can also pass a conversation to support ("Send this to support"). Marty answers every ticket himself; there is no support email address, point people to ${SITE_URL}/support instead. Tickets share one desk with the rest of the Crypto Team Build Network.
- Leaderboard at ${SITE_URL}/leaderboard ranks members by packages sold to direct referrals (weekly, monthly, all time; prizes are credits, never cash). Release notes and roadmap at ${SITE_URL}/whats-new.
- InstantAdPay is the sister property in the same network, not this site: it is the ad marketplace (buy ad packages, earn credits by viewing ads, get paid when your line buys); LinkSpin is the tool side (rotator, page builder, zones), free with an email, whose packages buy ad delivery across the LinkSpin viewer, member zones and the partner network and pay the same sponsor line in the purchase transaction. Username, sponsor and profile (avatar, bio, social links) carry over when the member signs in with the same email, and can be changed here any time. Do not describe InstantAdPay mechanics (holding-tank rescue emails, Five Dollar Friday, Wired Wednesday, games, mint passes, surf earn tab) as LinkSpin features.
RULES:
- 1 to 4 sentences, plain text, no markdown, include full URLs when pointing at a page.
- NEVER promise or estimate income. This is an advertising service with a referral program, never an investment. Be honest about risk: crypto transactions are irreversible, nobody earns unless real ad purchases happen in their line.
- No em dashes. If you do not know, say so and point to ${SITE_URL}/contract or the ledger.`;
- No em dashes. If you do not know, say so and point to ${SITE_URL}/contract or the ledger.
- Anything about one person's own account (a missing payout, a sign-in that will not work, a charge, a bug) you cannot look up: say so and point them to Help at ${SITE_URL}/help, or ${SITE_URL}/support when signed out.`;
}
function askAI(message, historyText) {
@@ -133,15 +139,17 @@ function askAI(message, historyText) {
});
}
const UNSURE_RE = /(not sure|do not know|don't know|cannot help|can't help|unable to help|no way for me|i (can|could) not (see|check|look)|contact support|reach support|support (ticket|desk)|\/support\b|\/help\b)/i;
async function answer(message, historyText) {
const msg = String(message || '').trim();
if (!msg) return { error: 'Say something first.' };
for (const c of CANNED) if (c.re.test(msg)) return { reply: c.a, canned: true };
if (!enabled()) return { reply: 'Good question. The quick answers I have cover spin links, pages, zones, packages, the payout split, qualification and joining; for anything deeper, the plain-language contract review at ' + SITE_URL + '/contract and the publisher page at ' + SITE_URL + '/publishers cover most of it.' };
try { return { reply: await askAI(msg, historyText) }; }
for (const c of CANNED) if (c.re.test(msg)) return Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
if (!enabled()) return { reply: 'Good question. The quick answers I have cover spin links, pages, zones, packages, the payout split, qualification and joining; for anything deeper, the plain-language contract review at ' + SITE_URL + '/contract covers most of it, or tap "Send this to support" and Marty will answer.', handoff: true };
// handoff: the answer admits it cannot help, so the widget offers "Send this to support"
try { const reply = await askAI(msg, historyText); return Object.assign({ reply }, UNSURE_RE.test(reply) ? { handoff: true } : {}); }
catch (e) {
console.error('chat AI failed', e.message);
return { reply: 'I hit a snag answering that one. The contract review at ' + SITE_URL + '/contract and the live ledger at ' + SITE_URL + '/ledger cover most deep questions.' };
return { reply: 'I hit a snag answering that one. The contract review at ' + SITE_URL + '/contract and the live ledger at ' + SITE_URL + '/ledger cover most deep questions, or tap "Send this to support" and Marty will answer.', handoff: true };
}
}
+49
View File
@@ -0,0 +1,49 @@
// Help desk bridge (Marty 2026-10-16: ONE shared desk, in the InstantAdPay admin, tickets tagged by platform; only Marty
// answers, there or from Telegram). LinkSpin keeps no tickets of its own: the Help screen (/help), the public /support
// page, the private ticket link (/support/t/<token>) and the chat hand-off all call InstantAdPay's partner API, signed
// exactly like the registry rows in iapsync.js:
// POST <IAP_URL>/api/partner/support/<op> ops: create, list, view, reply, token, token-reply
// headers X-LS-Ts (ms) + X-LS-Sig = hex HMAC-SHA256(ts + "\n" + rawBody) with LS_SYNC_SECRET (the same ONE secret)
// LinkSpin runs the person-facing guards (session, honeypot, form age, icon check) and vouches for the email it sends;
// InstantAdPay only touches platform 'linkspin' tickets (LS- refs) and words their emails and links as LinkSpin's.
// Inert (answers "not connected") while the secret is missing or short. No attachments: uploads live on this volume,
// which the desk on InstantAdPay cannot show.
'use strict';
const crypto = require('crypto');
const URL_ = () => String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '');
const SECRET = () => String(process.env.LS_SYNC_SECRET || '').trim();
const on = () => SECRET().length >= 32;
const OFF = { status: 503, data: { error: 'Support is not connected right now. Try again in a little while.' } };
// resolves { status, data } and never throws: the routes pass both straight to the browser
async function call(op, body) {
if (!on()) return OFF;
const raw = JSON.stringify(body || {}); const ts = String(Date.now());
const sig = crypto.createHmac('sha256', SECRET()).update(ts + '\n' + raw).digest('hex');
try {
const r = await fetch(URL_() + '/api/partner/support/' + op, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-LS-Ts': ts, 'X-LS-Sig': sig }, body: raw, signal: AbortSignal.timeout(15000) });
let data = null; try { data = await r.json(); } catch (e) {}
if (!data || typeof data !== 'object') return { status: 502, data: { error: 'Support did not answer properly. Try again in a minute.' } };
if (r.status === 401 || r.status === 503) { console.error('helpdesk', op, r.status, data.error); return OFF; } // our wiring, not the member's fault
if (op === 'list' && r.status === 200 && body && body.email) unreadCache.set(String(body.email).toLowerCase(), { n: Number(data.unread) || 0, at: Date.now() }); // a fresh list is a fresh badge
return { status: r.status, data };
} catch (e) {
console.error('helpdesk', op, e.message);
return { status: 502, data: { error: 'Support could not be reached just now. Try again in a minute.' } };
}
}
// unread badge: one small cached count per email, so every Control Room page load does not cost a round trip
const unreadCache = new Map(); // email -> { n, at }
async function unread(email) {
const k = String(email || '').toLowerCase(); const c = unreadCache.get(k);
if (c && Date.now() - c.at < 60000) return c.n;
if (unreadCache.size > 5000) unreadCache.clear();
const r = await call('list', { email: k }); // sets the cache on success
if (r.status !== 200) { unreadCache.set(k, { n: 0, at: Date.now() }); return 0; }
return Number(r.data.unread) || 0;
}
const forget = email => unreadCache.delete(String(email || '').toLowerCase());
module.exports = { call, unread, forget, on };
+1 -1
View File
@@ -450,7 +450,7 @@
</div>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/admin.js?v=20261012a"></script>
</body>
</html>
+1 -1
View File
@@ -61,7 +61,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/ads-screen.js?v=20261008b"></script>
</body>
</html>
+64 -2
View File
@@ -1,4 +1,7 @@
// 24/7 assistant widget: floating bubble, slide-up panel, /api/chat.
// Hand-off (help desk, 2026-10-16): when the answer cannot help, or they ask for a person, the widget offers
// "Send this to support", which files the last few turns as a ticket on the shared desk (members: their Help
// screen; signed out: their email, behind the same invisible walls as sign-up).
(function () {
const root = document.createElement('div');
root.id = 'iapChat';
@@ -7,10 +10,11 @@
+ '<div class="ch-head"><b>Ask anything</b><span class="ch-sub">Real answers, around the clock</span>'
+ '<button id="iapChatClose" aria-label="Close chat" type="button">×</button></div>'
+ '<div class="ch-msgs" id="iapChatMsgs">'
+ '<div class="ch-m bot">Hey. Ask me how the payments work, what the packages buy, or anything else. Straight answers only, no income hype.</div>'
+ '<div class="ch-m bot">Hey. Ask me how the payments work, what the packages buy, or anything else. Straight answers only, no income hype. Need a person instead? Tap <b>Send this to support</b> below, open <a href="/help" style="color:inherit;text-decoration:underline">Help</a>, or use the <a href="/support" style="color:inherit;text-decoration:underline">support page</a>.</div>'
+ '</div>'
+ '<div class="ch-input"><input id="iapChatIn" placeholder="Type your question…" maxlength="600">'
+ '<button id="iapChatSend" type="button">Send</button></div>'
+ '<div style="text-align:center;font-size:12px;padding:4px 0 8px"><a href="#" id="iapChatHuman" style="color:inherit;opacity:.75">Need a person? Send this to support</a></div>'
+ '</div>';
document.body.appendChild(root);
@@ -18,6 +22,7 @@
const msgs = $('iapChatMsgs');
const input = $('iapChatIn');
let history = [];
const turns = []; // { who: 'me' | 'bot', text } for the support hand-off
const add = (text, who) => {
const d = document.createElement('div');
@@ -29,11 +34,18 @@
msgs.scrollTop = msgs.scrollHeight;
return d;
};
function offerHandoff() {
if (msgs.querySelector('.ch-handoff')) return;
const d = document.createElement('div'); d.className = 'ch-m bot ch-handoff';
d.innerHTML = '<button type="button" class="btn small" style="margin:0">Send this to support</button>';
d.querySelector('button').addEventListener('click', handoff);
msgs.appendChild(d); msgs.scrollTop = msgs.scrollHeight;
}
async function send() {
const q = input.value.trim();
if (!q) return;
input.value = '';
add(q, 'me');
add(q, 'me'); turns.push({ who: 'me', text: q });
const wait = add('…', 'bot');
try {
const r = await (await fetch('/api/chat', { method: 'POST',
@@ -41,12 +53,61 @@
body: JSON.stringify({ message: q, history: history.slice(-4).join(' | ') }) })).json();
wait.remove();
add(r.reply || r.error || 'No answer came back. Try again.', 'bot');
if (r.reply) turns.push({ who: 'bot', text: r.reply });
history.push('Q: ' + q, 'A: ' + (r.reply || ''));
if (r.handoff) offerHandoff();
} catch (e) {
wait.remove();
add('Connection hiccup. Try that again.', 'bot');
offerHandoff();
}
}
async function post(body) {
const g = window.IAP && IAP.guard;
if (g) await g.formSettled();
return (await fetch('/api/support/chatbot', { method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(Object.assign({ transcript: turns.slice(-8), fts: g ? g.FORM_TS : 0 }, body)) })).json();
}
function done(r) {
const old = msgs.querySelector('.ch-handoff'); if (old) old.remove();
const f = msgs.querySelector('.ch-hform'); if (f) f.remove();
add(r.member ? 'Sent to support as ticket ' + r.ref + '. Marty will reply in Help in your Control Room and by email: ' + location.origin + r.link
: 'Sent to support as ticket ' + r.ref + '. We emailed you a private link to follow it, and Marty will reply there: ' + location.origin + r.link, 'bot');
}
async function handoff(e) {
if (e && e.preventDefault) e.preventDefault();
if (msgs.querySelector('.ch-hform')) return;
let me = null; try { me = await (await fetch('/api/me')).json(); } catch (err) {}
if (me && me.signedIn && me.email) {
const ok = window.IAP && IAP.confirmBox ? await IAP.confirmBox('Send this chat to support as a ticket? Marty will reply in Help in your Control Room and by email.', { ok: 'Send it', cancel: 'Not now' }) : true;
if (!ok) return;
try { const r = await post({}); if (r.error) throw new Error(r.error); done(r); } catch (err) { add(err.message || 'Could not send it. Try Help in your Control Room.', 'bot'); }
return;
}
// signed out: an email so Marty can reply, plus the same invisible walls as sign-up
const d = document.createElement('div'); d.className = 'ch-m bot ch-hform';
d.innerHTML = 'Where should Marty reply?'
+ '<input class="hp-field" type="text" tabindex="-1" aria-hidden="true" autocomplete="off" id="iapChatHp" style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0">'
+ '<input id="iapChatEmail" type="email" placeholder="your email" maxlength="190" autocomplete="email" style="width:100%;margin-top:6px;box-sizing:border-box">'
+ '<input id="iapChatNote" placeholder="anything to add (optional)" maxlength="600" style="width:100%;margin-top:6px;box-sizing:border-box">'
+ '<div id="iapChatCheck" hidden style="margin-top:6px"></div>'
+ '<button type="button" class="btn small" id="iapChatGo" style="margin-top:8px">Send to support</button> <span class="small" id="iapChatErr"></span>';
msgs.appendChild(d); msgs.scrollTop = msgs.scrollHeight;
$('iapChatEmail').focus();
$('iapChatGo').addEventListener('click', async () => {
const btn = $('iapChatGo'); if (btn.disabled) return; btn.disabled = true; $('iapChatErr').textContent = '';
try {
let pick = null, r = null;
for (let i = 0; i < 4; i++) {
r = await post({ email: $('iapChatEmail').value.trim(), note: $('iapChatNote').value.trim(), hp_field_x9: window.IAP && IAP.guard ? IAP.guard.hpValue($('iapChatHp')) : '', pick });
if (r.challenge && window.IAP && IAP.guard) { pick = await IAP.guard.iconCheck($('iapChatCheck'), r.challenge, r.error); continue; }
break;
}
if (!r || r.error) throw new Error((r && r.error) || 'Could not send it.');
done(r);
} catch (err) { $('iapChatErr').textContent = err.message; btn.disabled = false; }
});
}
$('iapChatBtn').addEventListener('click', () => {
const p = $('iapChatPanel');
p.hidden = !p.hidden;
@@ -54,5 +115,6 @@
});
$('iapChatClose').addEventListener('click', () => { $('iapChatPanel').hidden = true; });
$('iapChatSend').addEventListener('click', send);
$('iapChatHuman').addEventListener('click', handoff);
input.addEventListener('keydown', e => { if (e.key === 'Enter') send(); });
})();
+6 -2
View File
@@ -35,6 +35,7 @@ window.IAP = (function () {
+ '<a href="/leaderboard" data-p="leaderboard">Leaderboard</a>'
+ '<a href="/contract" data-p="contract">The contract</a>'
+ '<a href="/blog" data-p="blog">Blog</a>'
+ '<a href="/support" data-p="support">Support</a>'
+ '<a href="/links" data-p="my">Members</a>'
+ '</span><span id="navWallet" class="muted">…</span></div>';
document.body.prepend(nav);
@@ -55,7 +56,7 @@ window.IAP = (function () {
f.style.cssText = 'border-top:1px solid var(--line);margin-top:48px;padding:26px 22px;text-align:center;color:var(--muted);font-size:13px';
f.innerHTML = '<div>© ' + new Date().getFullYear() + ' LinkSpin</div>'
+ '<div style="margin-top:8px;display:flex;gap:16px;justify-content:center;flex-wrap:wrap">'
+ '<a href="/">How it works</a><a href="/ledger">Live ledger</a><a href="/contract">The contract</a><a href="/blog">Blog</a><a href="/leaderboard">Leaderboard</a><a href="/whats-new">What\'s new</a>'
+ '<a href="/">How it works</a><a href="/ledger">Live ledger</a><a href="/contract">The contract</a><a href="/blog">Blog</a><a href="/leaderboard">Leaderboard</a><a href="/whats-new">What\'s new</a><a href="/support">Support</a>'
+ '<a href="/terms">Terms</a><a href="/privacy">Privacy</a><a href="/disclaimer">Disclaimer</a></div>';
document.body.appendChild(f);
}
@@ -167,6 +168,8 @@ window.IAP = (function () {
}
armHoneypots(); document.addEventListener('DOMContentLoaded', armHoneypots);
const hpValue = el => (el && el.dataset.touched === '1') ? (el.value || '') : '';
// the support form and the chat hand-off reuse these walls (2026-10-16): wait out the form-age floor instead of bouncing a person
const formSettled = () => { const left = 2500 - (Date.now() - FORM_TS); return left > 0 ? new Promise(r => setTimeout(r, left)) : Promise.resolve(); };
async function requestCode(email, opts) {
const o = opts || {};
let pick = null;
@@ -245,5 +248,6 @@ window.IAP = (function () {
}
function ask(o) { return dialog(Object.assign({ type: 'text', value: '', placeholder: '' }, o || {})); }
function confirmBox(text, o) { return dialog(Object.assign({ type: 'none', text, ok: 'Yes', cancel: 'No' }, o || {})); }
return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, reportAd, requestCode, launchChecks, launchToggle, ask, confirmBox, $ };
return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, reportAd, requestCode, launchChecks, launchToggle, ask, confirmBox, $,
guard: { FORM_TS, iconCheck, hpValue, formSettled } }; // guard: the sign-up walls, reused by /support and the chat hand-off
})();
+14 -4
View File
@@ -20,11 +20,12 @@ window.CR = (function () {
['training', 'Training', '/tools#training', '<rect x="3" y="5" width="18" height="13" rx="2"/><path d="M10 9l5 2.5-5 2.5z"/>', 1],
['pipeline', 'Pipeline', '/tools#pipeline', '<rect x="3" y="5" width="5" height="14" rx="1"/><rect x="9.5" y="5" width="5" height="10" rx="1"/><rect x="16" y="5" width="5" height="7" rx="1"/>', 1],
['profile', 'Profile', '/tools#profile', '<circle cx="12" cy="8" r="3.5"/><path d="M5 20c0-4 3-6 7-6s7 2 7 6"/>', 1],
['help', 'Help', '/help', '<circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.4a2.5 2.5 0 0 1 4.8.9c0 1.7-2.4 2.2-2.4 3.7"/><path d="M12 17h.01"/>'],
['tools', 'More', '/tools', '<circle cx="5" cy="12" r="1.6"/><circle cx="12" cy="12" r="1.6"/><circle cx="19" cy="12" r="1.6"/>'],
];
// screens not built yet fall back to the classic dashboard pane so nothing is a dead end
const FALLBACK = {}; // the classic /my dashboard is retired (2026-10-08); its leftover panes live at /tools
const BUILT = new Set(['links', 'sources', 'pages', 'zones', 'ads', 'credits', 'reports', 'team', 'wallet', 'tools', 'promo', 'training', 'pipeline', 'profile']); // Training, Pipeline and Profile on the rail, not behind More (Marty 2026-10-11)
const BUILT = new Set(['links', 'sources', 'pages', 'zones', 'ads', 'credits', 'reports', 'team', 'wallet', 'tools', 'promo', 'training', 'pipeline', 'profile', 'help']); // Training, Pipeline and Profile on the rail, not behind More (Marty 2026-10-11); Help = support tickets (2026-10-16)
let ME = null, toastT;
function toast(msg, bad) { let t = $('crToast'); if (!t) { t = document.createElement('div'); t.id = 'crToast'; t.className = 'toast'; t.setAttribute('role', 'status'); document.body.appendChild(t); } t.textContent = msg; t.classList.toggle('bad', !!bad); t.classList.add('on'); clearTimeout(toastT); toastT = setTimeout(() => t.classList.remove('on'), 2000); }
async function api(path, body) { const r = await (await fetch(path, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body || {}) })).json(); if (r.error) throw new Error(r.error); return r; }
@@ -51,7 +52,7 @@ window.CR = (function () {
const page = $('page'); if (!page) return;
const app = document.createElement('div'); app.className = 'app'; let railWide = true; try { railWide = localStorage.getItem('cr.rail') !== 'narrow'; } catch (e) {} if (railWide) app.classList.add('wide'); // expanded by default (Marty 2026-10-08), the choice remembered per browser
app.innerHTML = '<nav class="rail" aria-label="LinkSpin"><a class="mark" href="/" aria-label="LinkSpin home" title="LinkSpin"></a>'
+ NAV.map(([k, label, href, svg, sec]) => '<a href="' + (BUILT.has(k) ? href : FALLBACK[k]) + '"' + (k === o.active ? ' class="on' + (sec ? ' rsec' : '') + '" aria-current="page"' : (sec ? ' class="rsec"' : '')) + ' title="' + label + '" aria-label="' + label + '"><svg viewBox="0 0 24 24">' + svg + '</svg><span class="lbl">' + label + '</span></a>').join('')
+ NAV.map(([k, label, href, svg, sec]) => '<a ' + (k === 'help' ? 'id="crHelp" ' : '') + 'href="' + (BUILT.has(k) ? href : FALLBACK[k]) + '"' + (k === o.active ? ' class="on' + (sec ? ' rsec' : '') + '" aria-current="page"' : (sec ? ' class="rsec"' : '')) + ' title="' + label + '" aria-label="' + label + '"><svg viewBox="0 0 24 24">' + svg + '</svg><span class="lbl">' + label + '</span></a>').join('')
+ '<span class="sp"></span><button class="railtog" type="button" id="crRailTog" title="Collapse or expand the menu" aria-label="Collapse or expand the menu"><svg viewBox="0 0 24 24"><path d="M15 6l-6 6 6 6"/></svg><span class="lbl">Collapse</span></button></nav>'
+ '<div class="main"><div class="topbar"><div><div class="crumb">' + esc(o.crumb || 'Control room') + '</div><h1>' + esc(o.title || '') + '</h1></div><span class="readout" id="crSub">' + esc(o.sub || '') + '</span><span class="grow"></span><span id="crActions">' + (o.actions || '') + '</span><button class="who" type="button" id="crUserBtn" title="Account"><i id="crAv"></i><span id="crWho">Sign in</span></button></div><div id="crBody"></div>'
+ '<div class="strip" id="crStrip"><span><span class="dot off" id="stDot"></span>rotator <b id="stHealth">checking</b></span><span>served today <b id="stServed">·</b></span><span>zones live <b id="stZones">·</b></span><span>network <b id="stNet">·</b></span><span class="grow"></span><span id="stClock"></span></div></div>';
@@ -135,7 +136,16 @@ window.CR = (function () {
}
return m;
}
async function requireSession(onReady) { let m = await me(); whoPaint(m); if (m && m.signedIn) { strip(); m = await ensureUsername(m); await loginAd(); return onReady(m); } signInFlow(async r => { whoPaint(r); strip(); await loginAd(); onReady(r); }); }
// Help badge on the rail: how many of the member's tickets have a reply from Marty they have not opened (helpdesk.js)
async function helpBadge() {
const a = $('crHelp'); if (!a) return 0;
let n = 0; try { n = Number((await get('/api/my/support/unread')).unread) || 0; } catch (e) { return 0; }
if (!document.getElementById('crHelpCss')) { const st = document.createElement('style'); st.id = 'crHelpCss'; st.textContent = '.rail a .rbadge{position:absolute;top:3px;right:3px;min-width:16px;height:16px;padding:0 4px;border-radius:999px;background:var(--sig);color:#fff;font:700 10px/16px var(--mono);text-align:center;box-sizing:border-box}.rail.wide a .rbadge,.app.wide .rail a .rbadge{right:8px;top:50%;transform:translateY(-50%)}'; document.head.appendChild(st); }
let b = a.querySelector('.rbadge'); if (!n) { if (b) b.remove(); return 0; }
if (!b) { b = document.createElement('b'); b.className = 'rbadge'; a.appendChild(b); }
b.textContent = n > 9 ? '9+' : String(n); a.title = 'Help: ' + n + ' new repl' + (n === 1 ? 'y' : 'ies'); return n;
}
async function requireSession(onReady) { let m = await me(); whoPaint(m); if (m && m.signedIn) { strip(); helpBadge(); m = await ensureUsername(m); await loginAd(); return onReady(m); } signInFlow(async r => { whoPaint(r); strip(); helpBadge(); await loginAd(); onReady(r); }); }
// tiles with a sparkline and a delta chip (Instrument scheme, 2026-09-29): series = numbers oldest first
function sparkline(series) {
const s = (series || []).map(Number); if (s.length < 2 || !s.some(Boolean)) return '';
@@ -154,5 +164,5 @@ window.CR = (function () {
return '<div class="tile' + (o.hi ? ' hi' : '') + '"><span class="k">' + esc(o.k) + '</span><div class="row"><span class="v">' + o.v + (o.unit ? '<small>' + esc(o.unit) + '</small>' : '') + '</span>' + sparkline(o.series) + '</div>'
+ (o.delta ? '<span class="delta' + (o.delta.cls ? ' ' + o.delta.cls : '') + '">' + esc(o.delta.text) + '</span>' : '') + (o.note ? '<span class="muted mono" style="font-size:11px">' + esc(o.note) + '</span>' : '') + '</div>';
}
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow, tile, sparkline, delta };
return { esc, fmt, api, get, copy, dialog, toast, mount, sub, me, requireSession, signInFlow, tile, sparkline, delta, helpBadge };
})();
+1 -1
View File
@@ -85,7 +85,7 @@
if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. ') + 'Your first purchase waits until ' + (sp.claim.deadline ? new Date(sp.claim.deadline).toLocaleDateString() : 'they do') + ', then it goes ahead with the nearest member above who has one. Nothing was charged.';
if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts first (one free transaction).';
if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.';
return 'Your sponsor link could not be matched to a member. Message support before buying so ' + who + ' gets credit.';
return 'Your sponsor link could not be matched to a member. Send a ticket from Help (/help) before buying so ' + who + ' gets credit.';
}
async function linkWallet() { CR.toast('Check your wallet for the free link signature…'); await IAPWallet.signIn(); CR.toast('Wallet linked. Earnings pay there from now on.'); await load(); }
async function activate() {
+83
View File
@@ -0,0 +1,83 @@
// LinkSpin Help (2026-10-16): the member's support tickets. List, new ticket (same categories as the desk), thread,
// reply; a dot marks a ticket Marty answered that the member has not opened, and the rail badge counts them.
// Server: /api/my/support* in server.js, which proxy to the one shared desk on InstantAdPay (helpdesk.js).
// #t=LS-1042 opens that ticket (the link in reply emails); #new opens the form. Times in US Central.
(function () {
const $ = id => document.getElementById(id); const esc = CR.esc;
const CATS = ['Account & sign-in', 'Wallet & payouts', 'Buying packages', 'Ads & campaigns', 'Earning credits & games', 'Team & referrals', 'Other'];
const STATUS = { open: ['Open', 't'], waiting_on_member: ['Waiting on you', 'warn'], closed: ['Closed', 'dim'] };
const AUTHOR = { member: 'You', admin: 'Marty, LinkSpin support', system: 'LinkSpin' };
const when = ts => ts ? new Date(Number(ts)).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : '';
const linkify = s => esc(s).replace(/(https?:\/\/[^\s<]+[^\s<.,;:!?)\]])/g, '<a href="$1" target="_blank" rel="noopener nofollow">$1</a>');
const st = s => { const x = STATUS[s] || [s, 'dim']; return '<span class="tag ' + x[1] + '">' + esc(x[0]) + '</span>'; };
const host = () => $('helpBody');
CR.mount({ active: 'help', title: 'Help', sub: 'support tickets' });
async function list(openNew) {
host().innerHTML = '<div class="panel"><span class="muted">loading your tickets</span></div>';
let r; try { r = await CR.get('/api/my/support'); } catch (e) { host().innerHTML = '<div class="panel"><span>Could not load your tickets. ' + esc(e.message) + '</span></div>'; return; }
const ts = r.tickets || [];
CR.helpBadge(); // the list just refreshed the server's badge count (the rail's first paint may be up to a minute old)
CR.sub(ts.length + ' ticket' + (ts.length === 1 ? '' : 's') + (r.unread ? ' · ' + r.unread + ' new repl' + (r.unread === 1 ? 'y' : 'ies') : ''));
host().innerHTML = '<div class="panel"><h2>Help and support</h2><div class="ink2">Stuck on something? Send Marty a ticket. He reads every one and replies here, and you get an email when he does. Quick answers to common questions are in the chat bubble on More and in Training.</div>'
+ '<div class="acts"><button class="btn pri" type="button" id="hNew">New ticket</button><a class="btn" href="/support">Public support page</a></div></div>'
+ '<div class="panel" id="hForm" hidden></div>'
+ '<div class="tbl hl"><div class="hd"><span>Your tickets</span><span class="up">Updated</span><span>Status</span></div>'
+ (ts.length ? ts.map(t => '<div class="rw" data-ref="' + esc(t.ref) + '"><span style="min-width:0"><div class="sb">' + (t.unread ? '<span class="hdot" title="New reply"></span>' : '') + esc(t.subject) + '</div><div class="mt">' + esc(t.ref) + ' · ' + esc(t.category) + '</div></span>'
+ '<span class="mt up">' + esc(when(t.updated)) + '</span><span>' + st(t.status) + '</span></div>').join('')
: '<div class="rw" style="cursor:default"><span class="muted">No tickets yet. When you send one, it shows up here with Marty\'s replies.</span></div>')
+ '<div class="ft">one shared desk for the Crypto Team Build Network · Marty answers every ticket himself</div></div>';
host().querySelectorAll('.rw[data-ref]').forEach(el => el.addEventListener('click', () => { history.replaceState(null, '', '#t=' + el.dataset.ref); open(el.dataset.ref); }));
$('hNew').addEventListener('click', form);
if (openNew) form();
}
function form() {
const box = $('hForm'); box.hidden = false;
box.innerHTML = '<h2>New ticket</h2><div class="hf">'
+ '<label>What is it about?<select class="field" id="hnCat">' + CATS.map(c => '<option>' + esc(c) + '</option>').join('') + '</select></label>'
+ '<label>Subject<input class="field" id="hnSubject" maxlength="140" placeholder="A few words, like: my spin link stopped rotating"></label>'
+ '<label>Message<textarea class="field" id="hnBody" rows="6" maxlength="5000" placeholder="What happened, what you expected, and anything you already tried. Never send your recovery phrase or private key."></textarea></label>'
+ '<div class="acts"><button class="btn pri" type="button" id="hnSend">Send to support</button><button class="btn" type="button" id="hnCancel">Cancel</button><span class="hmsg" id="hnMsg"></span></div></div>';
$('hnCancel').addEventListener('click', () => { box.hidden = true; box.innerHTML = ''; });
const send = $('hnSend');
send.addEventListener('click', async () => {
if (send.disabled) return; send.disabled = true;
try {
const r = await CR.api('/api/my/support', { category: $('hnCat').value, subject: $('hnSubject').value, body: $('hnBody').value });
CR.toast('Sent: ticket ' + r.ref);
history.replaceState(null, '', '#t=' + r.ref); open(r.ref);
} catch (e) { const m = $('hnMsg'); m.className = 'hmsg bad'; m.textContent = e.message; send.disabled = false; }
});
$('hnSubject').focus();
}
async function open(ref) {
host().innerHTML = '<div class="panel"><span class="muted">loading</span></div>';
let v; try { v = await CR.get('/api/my/support/' + encodeURIComponent(ref)); }
catch (e) { host().innerHTML = '<div class="panel"><span>' + esc(e.message) + '</span><div class="acts"><a class="btn" href="#" id="hBack">Back to your tickets</a></div></div>'; wireBack(); return; }
draw(v); CR.helpBadge();
}
const wireBack = () => { const a = $('hBack'); if (a) a.addEventListener('click', e => { e.preventDefault(); history.replaceState(null, '', location.pathname); list(); }); };
function draw(v) {
const t = v.ticket;
CR.sub(t.ref + ' · ' + (STATUS[t.status] || [t.status])[0].toLowerCase());
host().innerHTML = '<div><a href="#" id="hBack">‹ All your tickets</a></div>'
+ '<div class="panel"><h2>' + esc(t.subject) + '</h2><div class="acts">' + st(t.status) + '<span class="mono muted" style="font-size:11px">' + esc(t.ref) + ' · ' + esc(t.category) + ' · opened ' + esc(when(t.created)) + '</span></div>'
+ v.messages.map(m => '<div class="sup-msg ' + esc(m.author) + '"><div class="sm-head"><b>' + esc(AUTHOR[m.author] || m.author) + '</b><span>' + esc(when(m.created)) + '</span></div><div class="sm-body">' + linkify(m.body) + '</div></div>').join('')
+ (t.status === 'closed' ? '<span class="muted">This ticket is closed. Write below and it opens again.</span>' : '') + '</div>'
+ '<div class="panel"><h2>Your reply</h2><div class="hf"><textarea class="field" id="hrBody" rows="4" maxlength="5000" placeholder="Add more detail or answer Marty here"></textarea>'
+ '<div class="acts"><button class="btn pri" type="button" id="hrSend">Send reply</button><span class="hmsg" id="hrMsg"></span></div></div></div>';
wireBack();
const btn = $('hrSend');
btn.addEventListener('click', async () => {
if (btn.disabled) return; btn.disabled = true;
try { const nv = await CR.api('/api/my/support/' + encodeURIComponent(t.ref) + '/reply', { body: $('hrBody').value }); draw(nv); CR.toast('Reply sent'); }
catch (e) { const m = $('hrMsg'); m.className = 'hmsg bad'; m.textContent = e.message; btn.disabled = false; }
});
}
function route() {
const ref = (/(?:^#|&)t=(LS-\d{4,9})/.exec(location.hash) || [])[1];
if (ref) return open(ref);
list(/^#new\b/.test(location.hash));
}
CR.requireSession(() => { route(); window.addEventListener('hashchange', route); });
})();
+1 -1
View File
@@ -2281,7 +2281,7 @@
if (sp.sponsorBlocked === 'claim' && sp.claim) return (sp.claim.nobody ? 'Nobody above you on LinkSpin has a wallet yet, so there is no one for the contract to pay. ' : who + ' has not linked a wallet on LinkSpin yet. They have until ' + new Date(sp.claim.deadline).toLocaleString() + ' to do it, and we have told them. ') + 'You can use everything else meanwhile; your purchase waits so it pays the right person.';
if (sp.sponsorBlocked === 'notActivated') return who + ' has not switched on payouts yet, so this purchase would credit the company instead of them. Ask them to switch on payouts (Wallet tab, one free transaction), then try again.';
if (sp.sponsorBlocked === 'rpc') return 'Could not confirm your sponsor on the chain just now. Try again in a minute; nothing was charged.';
return 'Your sponsor link could not be matched to a member. Message support before buying so ' + who + ' gets credit.';
return 'Your sponsor link could not be matched to a member. Send a ticket from Help (/help) before buying so ' + who + ' gets credit.';
}
$('activateBtn').addEventListener('click', busy($('activateBtn'), async () => {
const me = await (await fetch('/api/sponsor?intent=buy')).json();
+88
View File
@@ -0,0 +1,88 @@
// LinkSpin support (2026-10-16): the public /support form and the private ticket link page (/support/t/<token>).
// Both talk to this site's /api/support routes, which proxy to the one shared desk on InstantAdPay (helpdesk.js).
// They pass the curtain, so nothing here may depend on a route that does not (a failed /api/me just means signed out).
// Times show in US Central. Members follow up in the Control Room's Help screen (help-screen.js).
(function () {
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
const CATS = ['Account & sign-in', 'Wallet & payouts', 'Buying packages', 'Ads & campaigns', 'Earning credits & games', 'Team & referrals', 'Other'];
const STATUS = { open: 'Open', waiting_on_member: 'Waiting on you', closed: 'Closed' };
const AUTHOR = { member: 'You', admin: 'Marty, LinkSpin support', system: 'LinkSpin' };
const when = ts => ts ? new Date(Number(ts)).toLocaleString('en-US', { timeZone: 'America/Chicago', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) + ' CT' : '';
const linkify = s => esc(s).replace(/(https?:\/\/[^\s<]+[^\s<.,;:!?)\]])/g, '<a href="$1" target="_blank" rel="noopener nofollow">$1</a>');
const $ = id => document.getElementById(id);
async function call(path, body) {
const o = { method: body === undefined ? 'GET' : 'POST', headers: { Accept: 'application/json' } };
if (body !== undefined) { o.headers['Content-Type'] = 'application/json'; o.body = JSON.stringify(body); }
let r; try { r = await (await fetch(path, o)).json(); } catch (e) { throw new Error('Could not reach support. Check your connection and try again.'); }
if (r.error && !r.challenge) throw new Error(r.error);
return r;
}
const host = $('supMain'); if (!host) return;
const panel = (title, inner) => '<div class="tile">' + (title ? '<div class="ph"><h2>' + esc(title) + '</h2></div>' : '') + '<div class="pb">' + inner + '</div></div>';
function threadHtml(v) {
const t = v.ticket;
return '<div class="tile"><div class="ph"><h2>' + esc(t.subject) + '</h2><span class="sup-st ' + esc(t.status) + '">' + esc(STATUS[t.status] || t.status) + '</span></div><div class="pb">'
+ '<span class="mono muted" style="font-size:11px">' + esc(t.ref) + ' · ' + esc(t.category) + ' · opened ' + esc(when(t.created)) + '</span>'
+ v.messages.map(m => '<div class="sup-msg ' + esc(m.author) + '"><div class="sm-head"><b>' + esc(AUTHOR[m.author] || m.author) + '</b><span>' + esc(when(m.created)) + '</span></div><div class="sm-body">' + linkify(m.body) + '</div></div>').join('')
+ (t.status === 'closed' ? '<span class="muted" style="font-size:13px">This ticket is closed. Write below and it opens again.</span>' : '') + '</div></div>';
}
async function page() {
const m = /^\/support\/t\/([A-Za-z0-9_.-]{20,80})$/.exec(location.pathname);
if (m) return tokenPage(m[1]);
let me = null; try { me = await (await fetch('/api/me', { headers: { Accept: 'application/json' } })).json(); } catch (e) {}
const signedIn = !!(me && me.signedIn && me.email);
host.innerHTML = (signedIn ? panel('', '<span class="ink2" style="font-size:14px">You are signed in as <b>' + esc(me.username ? '@' + me.username : me.email) + '</b>. Your tickets and Marty\'s replies live in <a href="/help">Help in your Control Room</a>, the easiest place to follow up. This form works too and files the ticket under your account.</span>') : '')
+ '<div class="tile"><div class="ph"><h2>Send a ticket</h2><span class="meta">Marty reads every one</span></div><form class="pb" id="supForm" novalidate autocomplete="on">'
+ '<input class="hp-field" type="text" name="website_url" id="supHp" tabindex="-1" aria-hidden="true" autocomplete="off">'
+ (signedIn ? '' : '<label class="lbl" for="supName">Your name<input class="field" id="supName" maxlength="80" autocomplete="name"></label>'
+ '<label class="lbl" for="supEmail">Your email (replies go here)<input class="field" id="supEmail" type="email" maxlength="190" autocomplete="email" required></label>')
+ '<label class="lbl" for="supCat">What is it about?<select class="field" id="supCat">' + CATS.map(c => '<option>' + esc(c) + '</option>').join('') + '</select></label>'
+ '<label class="lbl" for="supSubject">Subject<input class="field" id="supSubject" maxlength="140" placeholder="A few words, like: my sign-in code does not arrive"></label>'
+ '<label class="lbl" for="supBody">Message<textarea class="field" id="supBody" rows="7" maxlength="5000" placeholder="What happened, what you expected, and anything you already tried. Never send your recovery phrase or private key."></textarea></label>'
+ '<div id="supCheck" hidden></div>'
+ '<div class="acts"><button class="btn pri" type="submit" id="supSend">Send to support</button><span class="msg" id="supMsg"></span></div>'
+ '</form></div>';
$('supForm').addEventListener('submit', async e => {
e.preventDefault();
const btn = $('supSend'); if (btn.disabled) return; btn.disabled = true;
const msg = $('supMsg'); msg.className = 'msg'; msg.textContent = 'Sending…';
const val = id => { const el = $(id); return el ? el.value : ''; };
try {
const g = IAP.guard; await g.formSettled();
let pick = null, r = null;
for (let i = 0; i < 4; i++) {
r = await call('/api/support', { name: val('supName'), email: val('supEmail'), category: val('supCat'), subject: val('supSubject'), body: val('supBody'),
fts: g.FORM_TS, hp_field_x9: g.hpValue($('supHp')), pick });
if (r.challenge) { msg.textContent = ''; pick = await g.iconCheck($('supCheck'), r.challenge, r.error); continue; }
break;
}
if (!r || !r.ok) throw new Error('Could not verify. Refresh the page and try again.');
host.innerHTML = panel('Got it. Your ticket is ' + r.ref, '<span class="ink2" style="font-size:14px">Marty reads every ticket and replies as soon as he can. '
+ (r.member ? 'His reply shows up in Help in your Control Room and in your email.' : 'We just emailed you a private link to this ticket, so you can check on it or add more detail without signing in. If it does not arrive, look in spam or promotions.') + '</span>'
+ '<div class="acts">' + (r.member ? '<a class="btn pri" href="/help#t=' + esc(r.ref) + '">Open it in Help</a>' : '<a class="btn pri" href="/support/t/' + esc(r.token) + '">View your ticket</a>') + '<a class="btn" href="/">Back to LinkSpin</a></div>');
window.scrollTo(0, 0);
} catch (err) { msg.className = 'msg bad'; msg.textContent = err.message; }
finally { btn.disabled = false; }
});
}
async function tokenPage(tok) {
const h = $('supH'); if (h) h.textContent = 'Your support ticket';
host.innerHTML = panel('', '<span class="muted">Loading your ticket…</span>');
let v; try { v = await call('/api/support/t/' + encodeURIComponent(tok)); }
catch (e) { host.innerHTML = panel('', '<span>' + esc(e.message) + '</span><div class="acts"><a class="btn pri" href="/support">Send a new ticket</a></div>'); return; }
const draw = v2 => {
host.innerHTML = threadHtml(v2) + panel('Your reply', '<textarea class="field" id="tkBody" rows="4" maxlength="5000" placeholder="Add more detail or answer Marty here"></textarea>'
+ '<div class="acts"><button class="btn pri" type="button" id="tkSend">Send reply</button><span class="msg" id="tkMsg"></span></div>'
+ '<span class="muted" style="font-size:12.5px">Keep this link private: anyone with it can read and answer this ticket. Members can also follow up from <a href="/help">Help in the Control Room</a>.</span>');
const btn = $('tkSend');
btn.addEventListener('click', async () => {
if (btn.disabled) return; btn.disabled = true;
try { const nv = await call('/api/support/t/' + encodeURIComponent(tok) + '/reply', { body: $('tkBody').value }); draw(nv); const mm = $('tkMsg'); mm.className = 'msg'; mm.textContent = 'Reply sent. Marty will see it.'; }
catch (e) { const mm = $('tkMsg'); mm.className = 'msg bad'; mm.textContent = e.message; btn.disabled = false; }
});
};
draw(v);
}
page();
})();
+1
View File
@@ -128,6 +128,7 @@
<span class="word">Link<b>Spin</b></span>
<a href="/">Home</a>
<a href="/ledger">Live ledger</a>
<a href="/support">Support</a>
<a href="/terms">Terms</a>
<a href="/privacy">Privacy</a>
<a href="/disclaimer">Disclaimer</a>
+3 -3
View File
@@ -78,9 +78,9 @@
</div>
</div>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/wallet.js?v=20261008a"></script>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/credits-screen.js?v=20261015a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/credits-screen.js?v=20261016a"></script>
</body>
</html>
+1
View File
@@ -41,6 +41,7 @@
<div class="wrap">
<span class="word">Link<b>Spin</b></span>
<a href="/">Home</a><a href="/contract">The contract</a><a href="/ledger">Live ledger</a><a href="/terms">Terms</a><a href="/privacy">Privacy</a>
<a href="/support">Support</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
+1 -1
View File
@@ -68,6 +68,6 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
</body>
</html>
+35
View File
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="robots" content="noindex, nofollow">
<title>Help · LinkSpin</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="stylesheet" href="/assets/cr.css?v=20261012a">
<style>
.body{padding:16px 24px;display:grid;gap:16px;max-width:980px}
.hl .hd,.hl .rw{grid-template-columns:minmax(0,1fr) 150px 130px}.hl .rw{cursor:pointer}
.hl .rw .sb{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hl .rw .mt{font-family:var(--mono);font-size:11px;color:var(--muted)}
.hdot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--sig);margin-right:6px;vertical-align:1px}
.hf{display:grid;gap:12px}
.hf label{display:grid;gap:5px;font-size:10.5px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
.hf textarea.field{font:500 14px var(--body, Manrope, system-ui);line-height:1.5;resize:vertical}
.acts{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.hmsg{font-size:12.5px;color:var(--muted)} .hmsg.bad{color:var(--bad)}
.sup-msg{border:1px solid var(--line);border-radius:8px;padding:12px 14px;background:var(--panel-2)}
.sup-msg.admin{border-color:var(--accent-dim, #7CB2FF);background:var(--accent-soft, #E1ECFC)}
.sup-msg .sm-head{font-size:12px;color:var(--muted);margin:0 0 6px;display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap}
.sup-msg .sm-body{white-space:pre-wrap;word-wrap:break-word;font-size:14.5px;line-height:1.5}
@media (max-width:900px){.body{padding:12px 16px}.hl .hd{display:none}.hl .rw{grid-template-columns:1fr auto}.hl .rw .up{display:none}}
</style>
</head>
<body>
<div id="page">
<div class="body" id="helpBody"><div class="panel"><span class="muted">loading</span></div></div>
</div>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/help-screen.js?v=20261016a"></script>
</body>
</html>
+2 -1
View File
@@ -28,7 +28,7 @@
<div class="wrap">
<a class="brand" href="/" aria-label="LinkSpin home"><span class="mark"></span><span class="word">Link<b>Spin</b></span></a>
<nav class="nav" aria-label="Site">
<a href="#links">Links</a><a href="#pages">Pages</a><a href="#zones">Zones</a><a href="#split">The split</a><a href="/ledger">Ledger</a><a href="/blog">Blog</a>
<a href="#links">Links</a><a href="#pages">Pages</a><a href="#zones">Zones</a><a href="#split">The split</a><a href="/ledger">Ledger</a><a href="/blog">Blog</a><a href="/support">Support</a>
</nav>
<span class="grow"></span>
<a href="/join" class="btn ghost" data-join>Sign in</a>
@@ -217,6 +217,7 @@
<a href="/terms">Terms</a>
<a href="/privacy">Privacy</a>
<a href="/disclaimer">Disclaimer</a>
<a href="/support">Support</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">Polygon · <a href="/contract" id="ftContract">contract</a> · a Crypto Team Build Network property</span>
</div>
+2 -1
View File
@@ -100,11 +100,12 @@ body.squeeze .card{position:sticky;top:16px}
<a href="/terms">Terms</a>
<a href="/privacy">Privacy</a>
<a href="/disclaimer">Disclaimer</a>
<a href="/support">Support</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/join.js?v=20261009b"></script>
</body>
</html>
+1 -1
View File
@@ -104,7 +104,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/launch.js?v=20260915b"></script>
</body>
</html>
+2 -1
View File
@@ -59,11 +59,12 @@
<a href="/terms">Terms</a>
<a href="/privacy">Privacy</a>
<a href="/disclaimer">Disclaimer</a>
<a href="/support">Support</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/ledger.js?v=20261007a"></script>
</body>
</html>
+1 -1
View File
@@ -135,7 +135,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/links.js?v=20261012a"></script>
</body>
</html>
+4 -4
View File
@@ -1007,12 +1007,12 @@
</div>
</div>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/tools.js?v=20261011a"></script>
<script src="/assets/wallet.js?v=20261008a"></script>
<script src="/assets/promo.js?v=20261009b"></script>
<script src="/assets/my.js?v=20261015a"></script>
<script src="/assets/chat.js?v=20260907l"></script>
<script src="/assets/my.js?v=20261016a"></script>
<script src="/assets/chat.js?v=20261016a"></script>
</body>
</html>
+1 -1
View File
@@ -72,7 +72,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/pages-screen.js?v=20261011a"></script>
</body>
</html>
+1 -1
View File
@@ -130,7 +130,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford to lose.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/partners.js?v=20261010a"></script>
</body>
</html>
+1 -1
View File
@@ -192,7 +192,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/plays.js?v=20260910b"></script>
</body>
</html>
+1
View File
@@ -47,6 +47,7 @@
<div class="wrap">
<span class="word">Link<b>Spin</b></span>
<a href="/">Home</a><a href="/contract">The contract</a><a href="/ledger">Live ledger</a><a href="/terms">Terms</a><a href="/disclaimer">Disclaimer</a>
<a href="/support">Support</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
+1
View File
@@ -281,6 +281,7 @@
<a href="/blog">Blog</a>
<a href="/terms">Terms</a>
<a href="/privacy">Privacy</a>
<a href="/support">Support</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
+1 -1
View File
@@ -70,7 +70,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/reports.js?v=20261012a"></script>
</body>
</html>
+1 -1
View File
@@ -123,7 +123,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/sources-screen.js?v=20261012a"></script>
</body>
</html>
+72
View File
@@ -0,0 +1,72 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Support | LinkSpin</title>
<meta name="description" content="Ask LinkSpin for help: send a support ticket and get a reply by email. Members can also use Help in the Control Room.">
<meta name="robots" content="noindex, follow">
<meta name="theme-color" content="#0B1424">
<link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700;800&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="icon" type="image/png" href="/logo-icon.png">
<link rel="stylesheet" href="/assets/pub.css?v=20261007b">
<style>
.sup{max-width:760px}
.sup .tile{padding:0}
.sup .pb{padding:16px 18px;display:flex;flex-direction:column;gap:14px}
.sup textarea.field{font:500 14px var(--body);line-height:1.5;resize:vertical}
.sup select.field{font:500 13px var(--body)}
.sup .acts{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.sup .msg{font-size:13px;color:var(--muted)} .sup .msg.bad{color:var(--bad)}
.sup .hp-field{position:absolute;left:-9999px;width:1px;height:1px;opacity:0;overflow:hidden}
.icon-check{display:flex;gap:8px;flex-wrap:wrap;margin:6px 0 0}
.icon-check .ic-btn{font-size:24px;line-height:1;padding:9px 12px;border-radius:8px;border:1px solid var(--line-strong);background:#FFF;cursor:pointer}
.icon-check .ic-btn:hover{border-color:var(--sig)}
.sup-st{font:700 10px var(--mono);letter-spacing:.06em;text-transform:uppercase;padding:3px 8px;border-radius:4px;border:1px solid var(--line-strong);white-space:nowrap}
.sup-st.open{color:var(--accent-hi);border-color:var(--accent-dim);background:var(--accent-soft)}
.sup-st.waiting_on_member{color:var(--warn);border-color:rgba(194,65,12,.4);background:var(--warn-soft)}
.sup-st.closed{color:var(--muted)}
.sup-msg{border:1px solid var(--line);border-radius:8px;padding:12px 14px;background:var(--panel-2)}
.sup-msg.admin{border-color:var(--accent-dim);background:var(--accent-soft)}
.sup-msg .sm-head{font-size:12px;color:var(--muted);margin:0 0 6px;display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap}
.sup-msg .sm-body{white-space:pre-wrap;word-wrap:break-word;font-size:15px;line-height:1.5;color:var(--ink)}
</style>
</head>
<body>
<header class="top">
<div class="wrap">
<a class="brand" href="/" aria-label="LinkSpin home"><span class="mark"></span><span class="word">Link<b>Spin</b></span></a>
<span class="eyebrow" style="color:var(--chrome-sub);padding-left:14px;border-left:1px solid var(--chrome-line)">Support</span>
<span class="grow"></span>
<a href="/links" class="btn ghost">Control Room</a>
</div>
</header>
<main class="sec" style="padding-top:44px">
<div class="wrap sup" style="gap:18px">
<div class="text" style="display:flex;flex-direction:column;gap:10px">
<h1 class="disp" id="supH" style="margin:0;font-size:40px;line-height:1.04">Ask for help</h1>
<p class="ink2" style="margin:0;font-size:15px">Tell us what is going on and Marty will reply by email. Members can also open <a href="/help">Help in the Control Room</a>, where every ticket and reply is kept.</p>
</div>
<div id="supMain"><div class="tile"><div class="pb"><span class="muted">Loading…</span></div></div></div>
<p class="muted" style="margin:0;font-size:13px">We will never ask for your recovery phrase or private key, and nobody from LinkSpin will message you first asking for money or wallet access.</p>
</div>
</main>
<footer class="foot">
<div class="wrap">
<span class="word">Link<b>Spin</b></span>
<a href="/">Home</a>
<a href="/contract">The contract</a>
<a href="/support">Support</a>
<a href="/terms">Terms</a>
<a href="/privacy">Privacy</a>
<a href="/disclaimer">Disclaimer</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
</footer>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/support.js?v=20261016a"></script>
</body>
</html>
+1 -1
View File
@@ -37,7 +37,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/team.js?v=20260929a"></script>
</body>
</html>
+1
View File
@@ -53,6 +53,7 @@
<div class="wrap">
<span class="word">Link<b>Spin</b></span>
<a href="/">Home</a><a href="/contract">The contract</a><a href="/ledger">Live ledger</a><a href="/privacy">Privacy</a><a href="/disclaimer">Disclaimer</a>
<a href="/support">Support</a>
<span class="grow"></span>
<span class="mono" style="font-size:11px">a Crypto Team Build Network property</span>
</div>
+1 -1
View File
@@ -34,7 +34,7 @@
<p><a href="/ledger">← Back to the live ledger</a> · <a href="/contract">Read the contract review</a></p>
</div>
</section>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/tx.js?v=20260906m"></script>
</body>
</html>
+1 -1
View File
@@ -47,7 +47,7 @@
</div>
</div>
</section>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/wall.js?v=20261008a"></script>
</body>
</html>
+1 -1
View File
@@ -31,7 +31,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/wallet-screen.js?v=20261009a"></script>
</body>
</html>
+1 -1
View File
@@ -121,7 +121,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never share your recovery phrase.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261009a"></script>
<script src="/assets/common.js?v=20261016a"></script>
<script src="/assets/wallets.js?v=20260911b"></script>
</body>
</html>
+1 -1
View File
@@ -41,7 +41,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/cr-shell.js?v=20261016a"></script>
<script src="/assets/zones-screen.js?v=20261010a"></script>
</body>
</html>
+119 -2
View File
@@ -38,6 +38,7 @@ const leaderboard = require('./leaderboard');
const toolkit = require('./toolkit');
const registry = require('./registry'); // network registry: who is who across properties (LinkSpin, 2026-09-15)
const iapsync = require('./iapsync'); // reverse registry sync: LinkSpin-first members reach InstantAdPay (2026-10-15)
const helpdesk = require('./helpdesk'); // support: Help screen, /support, ticket link, chat hand-off, all on InstantAdPay's one desk (2026-10-16)
const carry = require('./carry'); // sponsor carry-over: engine activation, claim window, notices
const rotator = require('./rotator');
const health = require('./health'); // destination health checks + auto-pause (2026-10-10)
@@ -253,6 +254,45 @@ function codeGuard(req, b) {
if (codeHits.size > 5000) for (const [k, v] of codeHits) { if (!v.t.length || now - v.t[v.t.length - 1] > 24 * 3600 * 1000) codeHits.delete(k); }
return null;
}
// Public support form + signed-out chat hand-off (2026-10-16): 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, on counters of their own so a
// support ticket never eats into anyone's sign-in codes. Returns null to allow, or { status, body }.
const SUPPORT_LIMITS = { ipHour: 5, ipDay: 15, emailHour: 3, emailDay: 8, globalPerMin: 20 };
const supportHits = new Map(); // 'ip:<ip>' | 'em:<email>' | 'tk:<token or ref>' -> [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;
if (!fts || now - fts < CODE_LIMITS.minFormMs) { guardLog(req, 'support form-age', b); return { status: 400, body: { error: 'Give the page a few seconds, then send again.' } }; }
if (now - fts > 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;
}
// what an anonymous visitor may load while the curtain is up: the support page, its ticket link, its API and the files they use
const SUPPORT_OPEN = new Set(['/support', '/api/support', '/api/support/chatbot', '/assets/pub.css', '/assets/common.js', '/assets/support.js', '/logo-icon.png', '/favicon-256.png']);
const supportOpen = p => SUPPORT_OPEN.has(p) || /^\/support\/t\/[A-Za-z0-9_.-]{20,80}$/.test(p) || /^\/api\/support\/t\/[A-Za-z0-9_.-]{20,80}(\/reply)?$/.test(p);
// burst alert: at most one message per 10 minutes, to the admin Telegram chat if set, else the admin email
function codeTrip(req, ip) {
codeAlert.trips += 1; codeAlert.ips.add(ip);
@@ -923,7 +963,8 @@ const server = http.createServer(async (req, res) => {
const p = u.pathname;
// zone endpoints run on other people's sites and show only ad creatives, so they pass the curtain
const zonePath = p === '/z.js' || p === '/z/nas' || p === '/p.js' || p === '/p.gif' || p.startsWith('/u/pages/') || p.startsWith('/api/zone/') || p.startsWith('/banners/linkspin-') || p.startsWith('/art/house-');
if (!zonePath && curtained(req, res, u)) return; // nothing below this line runs for an uninvited visitor
// support must reach everyone, invited or not (2026-10-16): someone locked out or not yet let in is exactly who needs it
if (!zonePath && !supportOpen(p) && curtained(req, res, u)) return; // nothing below this line runs for an uninvited visitor
// -- the rotator redirect: one hop, recorded, on any host (LinkSpin)
let rm = /^\/r\/([a-z0-9]{4,12})$/i.exec(p);
@@ -1213,6 +1254,80 @@ const server = http.createServer(async (req, res) => {
return json(res, r.error ? 400 : 200, r);
}
// -- help desk (2026-10-16, helpdesk.js): the tickets live on InstantAdPay's one shared desk; these routes check the
// person (session or the support guard) and proxy. Public side first: the /support form, the private ticket link,
// the chat hand-off. All three pass the curtain (supportOpen above).
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 helpdesk.call('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.status !== 200) return json(res, r.status, r.data);
helpdesk.forget(email);
return json(res, 200, { ok: true, ref: r.data.ref, token: r.data.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'))) {
if (req.method === 'GET') { const r = await helpdesk.call('token', { token: m[1] }); return json(res, r.status, r.data); }
const b = await readBody(req);
if (supportFlood('tk:' + m[1], 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 helpdesk.call('token-reply', { token: m[1], body: b.body });
return json(res, r.status, r.data);
}
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 Control Room 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 helpdesk.call('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.status !== 200) return json(res, r.status, r.data);
helpdesk.forget(email);
return json(res, 200, { ok: true, ref: r.data.ref, member: !!acct, link: acct ? '/help#t=' + r.data.ref : '/support/t/' + r.data.token });
}
// member side: the Help screen lists, opens and answers this member's LinkSpin tickets; the rail badge reads /unread
if (p === '/api/my/support/unread' && req.method === 'GET') {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 200, { unread: 0 });
return json(res, 200, { unread: await helpdesk.unread(s.email) });
}
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.' });
const email = String(s.email).toLowerCase();
if (req.method === 'GET') { const r = await helpdesk.call('list', { email }); return json(res, r.status, r.data); }
const b = await readBody(req);
if (supportFlood('em:' + email, 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(email);
const r = await helpdesk.call('create', { source: 'form', email, name: (a && a.username) || '', username: a && a.username, subject: b.subject, category: b.category, body: b.body });
if (r.status !== 200) return json(res, r.status, r.data);
return json(res, 200, { ok: true, ref: r.data.ref });
}
m = /^\/api\/my\/support\/(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 email = String(s.email).toLowerCase();
helpdesk.forget(email); // opening or answering a ticket changes the badge
if (req.method === 'GET') { const r = await helpdesk.call('view', { ref: m[1], email }); return json(res, r.status, r.data); }
const b = await readBody(req);
if (supportFlood('tk:' + m[1], 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 helpdesk.call('reply', { ref: m[1], email, body: b.body });
return json(res, r.status, r.data);
}
// -- 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') {
@@ -2208,7 +2323,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 (' + SITE_URL + '/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
@@ -3200,6 +3315,8 @@ const server = http.createServer(async (req, res) => {
if (p === '/team') return sendFile(res, path.join(PUBLIC_DIR, 'team.html'));
if (p === '/wallet') return sendFile(res, path.join(PUBLIC_DIR, 'wallet.html'));
if (p === '/credits') return sendFile(res, path.join(PUBLIC_DIR, 'credits.html')); // Control Room: buy packages, link wallet, payouts on (2026-10-07)
if (p === '/help') return sendFile(res, path.join(PUBLIC_DIR, 'help.html')); // Control Room: Help, the member's support tickets (2026-10-16)
if (p === '/support' || /^\/support\/t\/[A-Za-z0-9_.-]{20,80}$/.test(p)) return sendFile(res, path.join(PUBLIC_DIR, 'support.html')); // public form + private ticket link, open past the curtain
if (p === '/join') return serveJoinPage(res, '', '', null, []); // bare join: sponsor from the cookie if any (home-page CTAs)
if (p === '/admin') return sendFile(res, path.join(PUBLIC_DIR, 'admin.html'));
if (p === '/shorts') return sendFile(res, path.join(PUBLIC_DIR, 'shorts.html'));