Sponsors can message every member of their line: isDownlineOf walks up the member's sponsor chain (exact, uncapped) instead of the capped list of newest directs; listByReferrer cap 200 -> 2000 so big lines show older directs (Marty's follow-ups: 41 of 49 were refused 403)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-5
@@ -160,7 +160,7 @@ const J = {
|
||||
return Object.values(this.db.byEmail)
|
||||
.filter(a => set.has(String(a.sponsorRef || '')))
|
||||
.sort((a, b) => b.created - a.created)
|
||||
.slice(0, 200).map(pub);
|
||||
.slice(0, 2000).map(pub);
|
||||
},
|
||||
async linkWallet(e, a) {
|
||||
const acct = this.db.byEmail[e];
|
||||
@@ -329,7 +329,7 @@ const D = {
|
||||
const clean = refs.filter(Boolean).map(String);
|
||||
if (!clean.length) return [];
|
||||
const rows = await db.q('SELECT * FROM accounts WHERE sponsor_ref IN (' + clean.map(() => '?').join(',')
|
||||
+ ') ORDER BY created DESC LIMIT 200', clean);
|
||||
+ ') ORDER BY created DESC LIMIT 2000', clean);
|
||||
return rows.map(rowPub);
|
||||
},
|
||||
async linkWallet(e, a) {
|
||||
@@ -505,10 +505,16 @@ async function sponsorOf(email) {
|
||||
return s || null;
|
||||
}
|
||||
// is `memberEmail` anywhere in `sponsorEmail`'s downline (to `depth` levels)?
|
||||
// walks UP from the member through their sponsors (exact and uncapped): the old walk down the sponsor's line read
|
||||
// listByReferrer, which returns the newest directs only, so a big sponsor could not message an older direct (2026-11-17)
|
||||
async function isDownlineOf(sponsorEmail, memberEmail, depth = 3) {
|
||||
const target = String(memberEmail || '').toLowerCase();
|
||||
const levels = await downline(sponsorEmail, depth);
|
||||
return levels.some(L => L.members.some(m => String(m.email || '').toLowerCase() === target));
|
||||
const want = String(sponsorEmail || '').toLowerCase(); let cur = String(memberEmail || '').toLowerCase();
|
||||
if (!want || !cur || want === cur) return false;
|
||||
for (let i = 0; i < depth; i++) {
|
||||
const s = await sponsorOf(cur); if (!s || !s.email) return false;
|
||||
const e = String(s.email).toLowerCase(); if (e === want) return true; if (e === cur) return false; cur = e;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
async function getChatSettings(email) {
|
||||
const a = await byEmail(email);
|
||||
|
||||
Reference in New Issue
Block a user