Holding tank batches: throttled emails + round announcement (Marty 2026-11-15: "spread the emails out", "Post it to the new members area")
Assignments still happen at once. Only the assigned people's "X is now your sponsor" emails go into a MySQL outbox (tank_batch_outbox, survives deploys): tankBatchEmailsPerDay (100) per Central day, evenly spaced from tankBatchEmailStartHour 8 to tankBatchEmailEndHour 20 CT, oldest first, through the site mailer (unsubscribe rules + link). Right before each send: still with that sponsor, not unsubscribed, flagged, spam or erased, else skipped. Exactly once across app copies: MySQL lock + conditional UPDATE queued->sending + marks claim per row. The switch-on reminders for a batch person start when their email goes out. Telegram: one announcement per round for the CTB group's General topic (tankBatchAnnounce, tankBatchAnnounceChatId blank = the payments group, tankBatchAnnounceTopicId blank = General), with the ladder card image (banners/holding-tank-leads-1200x675.jpg): total, sponsors by level, how to qualify; then one card per sponsor in the payments topic, at least tankBatchFeedGapMin (2) minutes apart. Sponsor emails stay one digest per round. Admin: GET/POST /api/admin/tank/batches/mail (queued, sent today, next send, pause/resume), POST /api/admin/tank/batches/round (the normal round path). Preview shows the email plan. qa/tank-batch.test.mjs 78 checks (cap, window, skip-if-changed, two copies, pause). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -222,12 +222,14 @@ async function adopt(adopterEmail, who, note, opts) {
|
||||
const ttl = partner && Number(partner.ttlMs) > 0 ? Number(partner.ttlMs) : TTL_MS;
|
||||
const ad = await impl().add({ adoptee: target.email, adopter: e, ts: now, expires: now + ttl, status: 'open', note: (opts && opts.recordNote) || text });
|
||||
{ const rr = RS.load().ready[target.email]; if (rr && !rr.done) { rr.done = now; rr.adoptedBy = e; RS.save(); } } // the hold lifts: their sponsor resolves now
|
||||
if (!partner) payTrack(target.email, e, ad.id, auto); // switch-on-payouts reminders at 24 h and 72 h (payTick); a draft pick gets the adoption email only (Marty 2026-11-15)
|
||||
if (!partner && !(opts && opts.queueMail)) payTrack(target.email, e, ad.id, auto); // a batch person's reminders start when their queued email goes out (tankbatch.js), so they stay spread too // switch-on-payouts reminders at 24 h and 72 h (payTick); a draft pick gets the adoption email only (Marty 2026-11-15)
|
||||
const link = activateLink();
|
||||
try { await messages.sendChat(me.memberId || 0, e, target.email, text + '\n\n' + chatPayLine(link)); } catch (err) {}
|
||||
if (mailer && mailer.hasKey()) {
|
||||
// a holding tank batch (2026-11-15, Marty: "spread the emails out"): the same email, handed to the throttled queue (opts.queueMail)
|
||||
const queueMail = opts && typeof opts.queueMail === 'function' ? opts.queueMail : null;
|
||||
if (queueMail || (mailer && mailer.hasKey())) {
|
||||
try {
|
||||
await mailer.send(target.email, nameOf(me) + ' is now your sponsor on InstantAdPay',
|
||||
await (queueMail ? (to, subject, body) => queueMail({ to, subject, body, adoptionId: ad.id, sponsor: e }) : (to, subject, body) => mailer.send(to, subject, body))(target.email, nameOf(me) + ' is now your sponsor on InstantAdPay',
|
||||
(b4h ? 'BTC4Hits has closed, and your BTC4Hits account came over to InstantAdPay with the same email. ' : 'You joined InstantAdPay without a sponsor. ') + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + '\n\n' + mailPayBlock(nameOf(me), link, !!target.wallet) + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nInstantAdPay');
|
||||
} catch (err) {}
|
||||
if (auto) {
|
||||
@@ -740,5 +742,5 @@ async function adminView() {
|
||||
return { waiting: await waiting(), adoptions: recent.map(ad => Object.assign({}, ad, { adopteeName: names[ad.adoptee], adopterName: names[ad.adopter] })), cap: capOpen(), ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, aligned: alignedRecent(30), payReminders: payView() };
|
||||
}
|
||||
|
||||
module.exports = { batchEligibility, holdingOf, firstOnContract, inDownlineOf, markOf: email => impl().mark(String(email || '').toLowerCase()), _ready: { state: () => RS.load(), save: () => RS.save() }, _json: { state: () => J.db, save: () => J.save() } /* member erase (erase.js) */, partnerEligibility, openOf, closeAdoption, countAll, remoteCount: email => remoteCount(String(email || '').toLowerCase()), lockedWhy, inTank, setSponsorDeliberate: (email, token, by, note) => setSponsor(email, token, by, note), HOLD_MS, NOT_COUNTED,
|
||||
module.exports = { payTrack, batchEligibility, holdingOf, firstOnContract, inDownlineOf, markOf: email => impl().mark(String(email || '').toLowerCase()), _ready: { state: () => RS.load(), save: () => RS.save() }, _json: { state: () => J.db, save: () => J.save() } /* member erase (erase.js) */, partnerEligibility, openOf, closeAdoption, countAll, remoteCount: email => remoteCount(String(email || '').toLowerCase()), lockedWhy, inTank, setSponsorDeliberate: (email, token, by, note) => setSponsor(email, token, by, note), HOLD_MS, NOT_COUNTED,
|
||||
init, view, adopt, holdFor, markReady, readyRec, readyTick, autoAssign, payTick, payView, activateLink, PAY_R1_MS, PAY_R2_MS, alignToNetwork, alignedRecent, setClock, eligibility, READY_MS, release, sweep, rescueSweep, rescueInfo, markContacted, adminView, waiting, adoptable, adoptableOf, openedSince, leftText, inviteAsk, dismissInvite, nameSponsor, GRACE_MS, hasOwnBuy, recordGift, onFollow, summaryMap, summaryFor, historyMap, capOpen, TTL_MS, WARN_DAYS, RESCUE_DAYS, MAX_ADOPTIONS };
|
||||
|
||||
Reference in New Issue
Block a user