GET /api/admin/member-lookup (Marty 2026-11-14, network hub member lookup): read-only, behind the admin token; ?q=<wallet> | #<banner id> | <username> answers myData (banners, credits, rewards) plus known, record, purchases and sponsored (VBBShop Purchase rows with tx), contract, explorer. Smoke 245/245
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -500,6 +500,19 @@ const server = http.createServer(async (req, res) => {
|
||||
const per = {}; for (const e of L) { const k = e.owner; const r = per[k] || (per[k] = { address: k, username: e.username, cycles: 0, views: 0 }); r.cycles++; r.views += e.views; if (e.username) r.username = e.username; }
|
||||
return json(res, 200, { entries: L.slice(-n).reverse(), members: Object.values(per).sort((a, b) => b.views - a.views), note: 'v1 records rewards only; nothing has been credited to InstantAdPay or LinkSpin.' });
|
||||
}
|
||||
// the network hub's member lookup (Marty 2026-11-14, read-only). GET ?q=<wallet> | #<banner id> | <username>. No email lives here.
|
||||
if (p === '/api/admin/member-lookup' && req.method === 'GET') {
|
||||
const q = String(u.searchParams.get('q') || '').trim(); let a = null, via = null;
|
||||
if (ADDR_RE.test(q)) { a = q.toLowerCase(); via = 'wallet'; }
|
||||
else if (/^#?\d{1,9}$/.test(q)) { const b = store.banner(Number(q.replace('#', ''))); a = b ? b.owner : null; via = 'banner'; }
|
||||
else if (NAME_RE.test(q)) { const m = store.memberByName(q); a = m ? m.address : null; via = 'username'; }
|
||||
if (!a) return json(res, 404, { error: 'not found' });
|
||||
const P = Object.entries(store.state().purchases || {}).map(([k, x]) => Object.assign({ tx: k.split(':')[0], logIndex: Number(k.split(':')[1]) }, x));
|
||||
const purchases = P.filter(x => x.buyer === a).sort((x, y) => (y.at || 0) - (x.at || 0)); const sponsored = P.filter(x => x.sponsor === a).sort((x, y) => (y.at || 0) - (x.at || 0));
|
||||
const m = store.member(a);
|
||||
return json(res, 200, Object.assign(m ? myData(a) : { address: a, banners: [], credits: 0 }, { via, known: !!m || purchases.length > 0 || sponsored.length > 0, record: m || null,
|
||||
purchases: purchases.slice(0, 100), sponsored: sponsored.slice(0, 100), contract: C.contractAddress, explorer: C.explorer }));
|
||||
}
|
||||
return json(res, 404, { error: 'Not found' });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user