Buyer names: an admin wallet alias (POST /api/admin/wallet-alias {wallet, username}, a MySQL document) for members who bought from a second wallet (bizventures, spot #3, Marty 2026-11-14); the sale toast shows a short wallet instead of 'A member' when no name is known; common.js?v=20261114a. Smoke 76/76

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-14 07:38:06 -06:00
parent 2c0e0dcedc
commit 7c2aab8f65
9 changed files with 19 additions and 9 deletions
+11 -1
View File
@@ -97,7 +97,11 @@ async function netMember(q) {
if (m) netCache.set('a:' + m.address, { at: Date.now(), m });
return m;
}
const nameOf = async addr => { const m = await netMember({ a: addr }); return m && m.address === addr.toLowerCase() ? m.username : null; };
// extra wallets a member bought with (Marty 2026-11-14: bizventures bought spot #3 from a second wallet the network does not know):
// wallet -> network username, set by the admin; wallet-aliases.json is a MySQL document (docstore)
const ALIAS_F = () => path.join(C.dataDir, 'wallet-aliases.json');
function aliases() { try { return JSON.parse(fs.readFileSync(ALIAS_F(), 'utf8')); } catch (e) { return {}; } }
const nameOf = async addr => { const al = aliases()[String(addr || '').toLowerCase()]; if (al) return al.username; const m = await netMember({ a: addr }); return m && m.address === addr.toLowerCase() ? m.username : null; };
// ---- LinkSpin Banner Spins for My Spots (Marty 2026-11-13: pull a Banner Spin in with a couple of clicks) ----
// Signed with NETWORK_SSO_SECRET: X-Net-Ts + X-Net-Sig = hex HMAC-SHA256('net.v1.' + ts + newline + raw body). LinkSpin answers
// for the account holding the signed-in wallet only.
@@ -465,6 +469,12 @@ const server = http.createServer(async (req, res) => {
}
// returning-member results: personal links opened, and how many of those visitors went on to buy (matched by the wallet that
// signed in on the same browser is not tracked; this counts link opens and new members since the first open)
if (p === '/api/admin/wallet-alias' && req.method === 'POST') { // {wallet, username} adds; {wallet, remove: true} drops
const tok = process.env.ADMIN_TOKEN; if (!tok || req.headers['x-admin-token'] !== tok) return json(res, 401, { error: 'no' });
const b = await readBody(req); const w = String(b.wallet || '').toLowerCase(); if (!/^0x[0-9a-f]{40}$/.test(w)) return json(res, 400, { error: 'wallet' });
const al = aliases(); if (b.remove) delete al[w]; else { const un = String(b.username || '').trim(); if (!/^[A-Za-z0-9_.-]{2,40}$/.test(un)) return json(res, 400, { error: 'username' }); al[w] = { username: un, at: Date.now(), note: String(b.note || '').slice(0, 200) }; }
fs.writeFileSync(ALIAS_F(), JSON.stringify(al)); return json(res, 200, { ok: true, aliases: al });
}
if (p === '/api/admin/welcome-stats' && req.method === 'GET') {
const tok = process.env.ADMIN_TOKEN; if (!tok || req.headers['x-admin-token'] !== tok) return json(res, 401, { error: 'no' });
let v = {}; try { v = JSON.parse(fs.readFileSync(path.join(C.dataDir, 'welcome-visits.json'), 'utf8')); } catch (e) {}