diff --git a/server.js b/server.js index 46c8f1f..d633451 100644 --- a/server.js +++ b/server.js @@ -519,7 +519,11 @@ async function notifyNewReferral(ref, newAcct) { // how a member is named in emails/alerts: @username, a linked position named after its owner, else member #id async function memberLabel(id) { try { - const a = await accounts.byMemberId(id); + let a = await accounts.byMemberId(id); + if (!a) { // brand-new buyer: the account learns its member id on its next page load, so read the + // wallet from the chain and match it now (Jim's purchase mailed as "member #25", 2026-09-13) + try { const m = await chain.member(id); if (m && m.account) { a = await accounts.byAddress(String(m.account).toLowerCase()); if (a && !a.memberId) accounts.setMemberId(a.email, id).catch(() => {}); } } catch (e) {} + } if (a && a.username) return '@' + a.username; const pos = await accounts.positionByMember(id); if (pos && pos.email) { const o = await accounts.byEmail(pos.email); if (o && o.username) return '@' + o.username + ' (extra position #' + id + ')'; }