Support tickets are members-only (Marty 2026-10-24, after a throwaway-address 'pentest' ticket IAP-1012): signed-out support form + chatbot handoff need an email that belongs to an account on this site; inbound email opens NEW tickets only for member emails (replies to existing tickets still land)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -334,6 +334,10 @@ 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
|
||||
// tickets are open to platform members only (Marty, 2026-10-24, after a throwaway-address 'pentest' ticket):
|
||||
// a signed-out sender's email must belong to an account on this site
|
||||
const MEMBER_ONLY_TICKET_MSG = "Support tickets are for LinkSpin members. Use the email on your LinkSpin account, or sign in first. Not a member yet? Join free at https://linkspin.app/join and ask from inside.";
|
||||
async function memberOnlyTicket(email) { try { return (await accounts.byEmail(email)) ? null : { status: 403, body: { error: MEMBER_ONLY_TICKET_MSG, membersOnly: true } }; } catch (e) { return null; } }
|
||||
function supportGuard(req, b, email) {
|
||||
const now = Date.now();
|
||||
const hpRaw = String(b.hp_field_x9 || '').trim();
|
||||
@@ -1603,6 +1607,7 @@ const server = http.createServer(async (req, res) => {
|
||||
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.' });
|
||||
if (!acct) { const iss = await newEmailIssue(email); if (iss) return json(res, 400, { error: iss.error, suggestion: iss.suggestion }); } // replies must reach them
|
||||
if (!acct) { const mo = await memberOnlyTicket(email); if (mo) return json(res, mo.status, mo.body); }
|
||||
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 });
|
||||
@@ -1625,7 +1630,7 @@ const server = http.createServer(async (req, res) => {
|
||||
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); }
|
||||
else { const mo = await memberOnlyTicket(email); if (mo) return json(res, mo.status, mo.body); 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());
|
||||
|
||||
Reference in New Issue
Block a user