My line: show payouts from an email-only session and across all owned positions

refreshMemberId falls back to the account's on-chain id when the session has no
wallet address (phone sign-in by email code), without caching it into the
session. /api/my/line now sums TierPaid events to every position the account
owns (main id + linked positions), so each direct's 'paid you so far' is right
from any device.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-12 04:46:22 -05:00
parent 1fd61eca56
commit b844a227d3
2 changed files with 14 additions and 4 deletions
+9 -1
View File
@@ -146,7 +146,15 @@ async function fromRequest(req) {
return impl().get(decodeURIComponent(m[1]));
}
async function refreshMemberId(sess) {
if (!sess || !sess.address) return (sess && sess.memberId) || 0;
if (!sess) return 0;
if (!sess.address) {
if (sess.memberId) return sess.memberId;
// email-only session (phone sign-in with no wallet connected): read the account's
// on-chain id instead, so read-only views (My line, earnings, P&L) work from any
// device. Not cached into the session: a session without an address stays wallet-less.
if (sess.email) { try { const a = await require('./accounts').byEmail(sess.email); if (a && a.memberId) return a.memberId; } catch (e) {} }
return 0;
}
try {
const id = await chain.memberIdByAccount(sess.address);
if (id && id !== sess.memberId) await updateSession(sess.token, { memberId: id });