Actually fix the missing joiner alert — the org test, not the emit
My previous fix was at the wrong layer. Proof: the announced-once set shows a "reg:" key written at 13:53:40, so the registered event fired correctly. It was being discarded one layer later. The real cause: the team-topic filter asks isInTeam(newMemberId), which walks uplineId — and a brand-new member has no uplineId at the moment the event fires. The indexer wires the matrix in a SEPARATE pass after the log loop (chain.js:359), so at emit time the walk has nothing to follow, the org test returns false, and the announcement is dropped. Payouts survive because they reference existing members whose uplines are already known. That asymmetry is exactly what Marty kept seeing: the member who got paid, never the joiner. Registered events now test the referrer as well. The referrer is always already wired, and anyone joining under someone in the org is in the org, so it is correct as well as available. Confirmed on #255: uplineId 246, referrerId 246 — the referrer was resolvable the whole time. Keeping the announced-once change from before: it fixes a real second bug (snapshot landing first suppressed the emit) and both had to be right. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1573,7 +1573,17 @@ chain.startIndexer(evt=>{
|
||||
const c=getConfig();
|
||||
// teamRootId accepts a comma list ("21,136") — alerts fire for ANY listed org
|
||||
const roots=String(c.teamRootId||'').split(',').map(n=>Number(n.trim())).filter(n=>n>0);
|
||||
const ids=evt.type==='payout'?[evt.toId,evt.fromId]:[evt.id];
|
||||
// A brand-new member has no uplineId yet at the moment the 'registered'
|
||||
// event fires: the indexer wires the matrix in a SEPARATE pass after the
|
||||
// log loop. So isInTeam(newId) walks nothing, returns false, and the
|
||||
// announcement is silently dropped — while the payout it triggered goes
|
||||
// out, because that references existing members whose uplines are known.
|
||||
// That was the "payout with no joiner beside it" Marty kept seeing.
|
||||
// The referrer is always already wired, and if they are in the org so is
|
||||
// anyone joining under them, so test them too.
|
||||
const ids=evt.type==='payout'?[evt.toId,evt.fromId]
|
||||
:evt.type==='registered'?[evt.id,evt.referrerId]
|
||||
:[evt.id];
|
||||
if(roots.length&&ids.some(i=>roots.some(r=>chain.isInTeam(i,r)))){
|
||||
const contact=id=>{const s=getSponsors().find(x=>String(x.id)===String(id));return s&&s.email?`\nContact: ${s.name?s.name+' — ':''}${s.email}`:''};
|
||||
let text;
|
||||
|
||||
Reference in New Issue
Block a user