Fix referral attribution (username joins) + broadcast rate-limit regression

- Dashboard "Your line" roster now matches referrals joined under the member's
  USERNAME link (invite link is /join/<username>), not just code + member id —
  username joins were invisible.
- lastBroadcastAt now counts only kind='broadcast'. Chat rides the same table,
  so chatting had been tripping the once-a-day broadcast limit ("try again in
  24h" on the first broadcast).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-07 06:38:27 -05:00
parent 7caff0eea2
commit 41d3293486
4 changed files with 11 additions and 4 deletions
+3 -1
View File
@@ -513,9 +513,11 @@ const server = http.createServer(async (req, res) => {
out.earnedWei = earned.toString();
out.earnCount = n;
}
// who joined through this member (code and, once on-chain, numeric id)
// who joined through this member: their invite link uses username when set,
// else code, and the numeric id once on-chain — match all three
const refs = [];
if (acct && acct.code) refs.push(acct.code);
if (acct && acct.username) refs.push(acct.username);
if (memberId) refs.push(String(memberId));
const joined = await accounts.listByReferrer(refs);
out.referrals = joined.map(r => ({