Login slots spell out the one-position rule (Michael Camire 2026-11-03: a reservation with 1,000 credits split 618 + 382 failed in a 2-second toast he never saw): GET /api/my/campaigns carries loginFunds (each position's free purchased credits); the composer shows "Paid from one position" with the per-position numbers and disables Launch/Reserve when no single position covers the slot; a login-specific 400 says nothing was charged and what to do; login failures open a dialog instead of a toast; chatbot fact; ads-screen.js?v=20261104lf, KNOWLEDGE_DATE 2026-11-04. loginqueue unit 13/13, e2e 36/36

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-04 07:23:46 -06:00
parent 33a6710909
commit cc7c1d36af
4 changed files with 24 additions and 7 deletions
+7 -1
View File
@@ -3743,6 +3743,10 @@ const server = http.createServer(async (req, res) => {
out.loginSlots = await ads.loginSlots(); // { max, used, queued, free, credits, days }: the Ads screen shows how many are open
out.loginQueue = await ads.myLoginQueue(s.email); // my paid reservations: place in line + estimated start (Central)
out.loginNext = await ads.loginNext(); // the place and estimated start a new reservation would get
// a login slot is paid from ONE position (Michael Camire 2026-11-03: 1,000 credits split 618 + 382 failed with a toast he never saw):
// the screen shows each position's free purchased credits and stops the buy before it is tried
try { const pool = await ads.balances((await myMemberIds(s)).ids, s.email);
out.loginFunds = { best: (pool.best.avail || 0) + (pool.credited || 0), credited: pool.credited || 0, per: pool.per.map(x => ({ memberId: x.memberId, avail: x.avail })) }; } catch (e) { out.loginFunds = null; }
out.creditLog = await ads.creditLog(s.email, 20); // credit activity (login slots, reservations, refunds)
out.editFee = editFee(); // credits per edit after each campaign's free one (the editor says which this is)
out.clickSources = await coach.clickSources(out.campaigns.map(c => c.id));
@@ -3775,8 +3779,10 @@ const server = http.createServer(async (req, res) => {
const fundId = pool.best.memberId || memberId;
const earnedNow = String(b.type) !== 'login' ? pool.earned : 0;
const budget = Math.floor(Number(b.budget) || 0);
if (String(b.type) === 'login' && pool.per.length > 1 && budget > pool.best.avail + pool.credited && budget <= pool.total)
return json(res, 400, { error: 'Nothing was charged. A login-ad slot costs ' + budget.toLocaleString('en-US') + ' purchased credits and is paid from ONE position. Your credits are spread across ' + pool.per.length + ' positions (' + pool.per.map(x => '#' + x.memberId + ': ' + x.avail.toLocaleString('en-US')).join(', ') + ' free), so none of them holds ' + budget.toLocaleString('en-US') + ' on its own. Buy a package on one position to bring it to ' + budget.toLocaleString('en-US') + ', or let a running campaign on it finish, then try again.', loginFunds: true });
if (pool.per.length > 1 && budget > pool.best.avail + pool.credited + earnedNow && budget <= pool.total + earnedNow)
return json(res, 400, { error: 'Your credits are spread across ' + pool.per.length + ' positions and one campaign spends from one of them. The largest single position holds ' + pool.best.avail + ' credits: set the budget to that or less, or run two campaigns.' });
return json(res, 400, { error:'Your credits are spread across ' + pool.per.length + ' positions and one campaign spends from one of them. The largest single position holds ' + pool.best.avail + ' credits: set the budget to that or less, or run two campaigns.' });
const r = await ads.createCampaign(s.email, fundId, b, ids);
return json(res, r.error ? 400 : 200, r);
}