Auto-enqueue rotation joins
A verified rotation join (@chriskelly8, ID 73 under #36) still required a manual "add to queue" step from the Telegram message and got missed. Rotation-path submissions now insert themselves into the sponsor queue as waiting positions (name from the submission, level from chain, parent = active sponsor, dedupe-guarded), and the Telegram alert reports the queue position instead of asking for action. #73 was added manually to catch up. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -148,7 +148,22 @@ async function handleSubmitId(req, res) {
|
|||||||
firePostback(clickid, `purchase-${clickid}`, source);
|
firePostback(clickid, `purchase-${clickid}`, source);
|
||||||
let msg;
|
let msg;
|
||||||
if (joinPath === 'rotation') {
|
if (joinPath === 'rotation') {
|
||||||
msg = `🔔 RM Circle: ROTATION JOIN CONFIRMED ✅\nName: ${memberName}\nNew ID: ${newId} (${onchain.tierName}, verified on-chain)\nJoined under rotation sponsor: #${onchain.referrerId}\nSource: ${source||'(direct)'}\n→ +1 direct for ID ${active.id}; add ${memberName} (ID ${newId}) to the rotation queue.`;
|
// rotation joins go straight into the queue as waiting positions — no manual step
|
||||||
|
let queueNote = '';
|
||||||
|
try {
|
||||||
|
let sponsors = getSponsors();
|
||||||
|
if (sponsors.some(s => String(s.id) === String(newId))) {
|
||||||
|
queueNote = 'Already in the rotation queue.';
|
||||||
|
} else {
|
||||||
|
const maxOrder = sponsors.reduce((m, s) => Math.max(m, s.sortOrder || 0), 0);
|
||||||
|
sponsors.push({ id: String(newId), name: memberName, parentId: String(active.id), directs: 0, level: onchain.levelName || 'Scintilla', status: sponsors.some(s => s.status === 'active') ? 'waiting' : 'active', sortOrder: maxOrder + 10, clicks: 0, notes: `auto-added: rotation join ${new Date().toISOString().slice(0, 10)}` });
|
||||||
|
sponsors = normalizeStatuses(sponsors);
|
||||||
|
saveSponsors(sponsors);
|
||||||
|
const waitingAhead = sponsors.filter(s => s.status === 'waiting' && (s.sortOrder || 0) < maxOrder + 10).length;
|
||||||
|
queueNote = `Auto-added to the rotation queue (${waitingAhead} waiting ahead of them).`;
|
||||||
|
}
|
||||||
|
} catch (e) { queueNote = `⚠ Auto-add to queue failed (${e.message}) — add manually.`; console.error('queue auto-add', e.message); }
|
||||||
|
msg = `🔔 RM Circle: ROTATION JOIN CONFIRMED ✅\nName: ${memberName}\nNew ID: ${newId} (${onchain.tierName}, verified on-chain)\nJoined under rotation sponsor: #${onchain.referrerId}\nSource: ${source||'(direct)'}\n✅ ${queueNote}\n(+1 direct for ID ${active.id} syncs from the chain automatically.)`;
|
||||||
} else if (joinPath === 'leg') {
|
} else if (joinPath === 'leg') {
|
||||||
msg = `🌱 RM Circle: TEAM-BUILD JOIN (not rotation)\nName: ${memberName}\nNew ID: ${newId} (${onchain.tierName}, verified on-chain)\nActual sponsor on-chain: #${onchain.referrerId}${sponsorId!=='?'&&String(onchain.referrerId)!==sponsorId?` (form said ${sponsorId})`:''}\nSource: ${source||'(direct)'}\n→ Leg growth under #${onchain.referrerId} — no rotation action needed. Add them to the rotation queue only if they want the team effort.`;
|
msg = `🌱 RM Circle: TEAM-BUILD JOIN (not rotation)\nName: ${memberName}\nNew ID: ${newId} (${onchain.tierName}, verified on-chain)\nActual sponsor on-chain: #${onchain.referrerId}${sponsorId!=='?'&&String(onchain.referrerId)!==sponsorId?` (form said ${sponsorId})`:''}\nSource: ${source||'(direct)'}\n→ Leg growth under #${onchain.referrerId} — no rotation action needed. Add them to the rotation queue only if they want the team effort.`;
|
||||||
} else if (joinPath === 'notfound') {
|
} else if (joinPath === 'notfound') {
|
||||||
|
|||||||
Reference in New Issue
Block a user