From 2e935b308139cfc1f2d19de1db46dba4dffe0bff Mon Sep 17 00:00:00 2001 From: martbost Date: Wed, 4 Nov 2026 14:38:17 -0600 Subject: [PATCH] Quest-site checks for Zealy (Marty 2026-11-04): POST /api/quest/zealy/account|wallet|member reads accounts.email or accounts.wallet from Zealy's API task call, checks X-Api-Key against QUEST_API_KEY, answers 200 (claimable) or 400 with a message that tells the member what to do (join link martbost, link a wallet, get a package). Read-only lookups; 503 until the key is set Co-Authored-By: Claude Opus 5.5 --- server.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server.js b/server.js index 549cc73..9d86bf0 100644 --- a/server.js +++ b/server.js @@ -3168,6 +3168,24 @@ const server = http.createServer(async (req, res) => { console.log('admin removed account', e); return json(res, 200, { ok: true }); } + // -- quest-site checks (Marty 2026-11-04: Zealy first). Zealy POSTs { accounts: { email?, wallet? } } with X-Api-Key; + // 200 = the member may claim, 400 + message = shown to them. Read-only: looks members up, never changes anything. + const questM = p.match(/^\/api\/quest\/zealy\/(account|wallet|member)$/); + if (questM && req.method === 'POST') { + const key = process.env.QUEST_API_KEY || ''; + if (!key) return json(res, 503, { message: 'Quest checks are not switched on yet.' }); + if (!gpSigOk(key, String(req.headers['x-api-key'] || ''))) return json(res, 401, { message: 'Bad API key.' }); + const b = await readBody(req); const ac = (b && b.accounts) || {}; + const em = String(ac.email || '').trim().toLowerCase(), w = String(ac.wallet || '').trim().toLowerCase(); + let acct = em ? await accounts.byEmail(em) : null; + if (!acct && /^0x[0-9a-f]{40}$/.test(w)) { acct = await accounts.byAddress(w); if (!acct) { const pos = await accounts.positionByAddress(w); if (pos && pos.email) acct = await accounts.byEmail(pos.email); } } + const JOIN = 'https://instantadpay.com/join/martbost'; + if (!acct) return json(res, 400, { message: em ? 'No InstantAdPay account uses ' + em + '. Join free at ' + JOIN + ' with this email, then claim again.' : 'No InstantAdPay account is linked to this wallet. Join free at ' + JOIN + ' and link this wallet in your dashboard, then claim again.' }); + if (questM[1] === 'wallet' && !acct.address) return json(res, 400, { message: 'Your InstantAdPay account has no Polygon wallet linked yet. Sign in at instantadpay.com/my, link your wallet, then claim again.' }); + if (questM[1] === 'member' && !acct.memberId) return json(res, 400, { message: 'Your InstantAdPay account is not an on-chain member yet. Get your first package at instantadpay.com/my, then claim again.' }); + console.log('quest check ok', questM[1], b && b.questId ? String(b.questId).slice(0, 40) : ''); + return json(res, 200, { message: 'Verified on InstantAdPay. Thanks for joining!' }); + } // -- release notes + roadmap (public read; admin write) (Marty, 2026-09-14) if (p === '/api/releases' && req.method === 'GET') return json(res, 200, releases.publicView()); // -- promo toolkit: tiers by badge + the AI Copy Engine (Surge+), credits beyond the free allowance