Top-ups: check the ad's own position, say where the free credits are, offer to pay from another
Bug: topUpCampaign read the position from the owner's campaign list, which does not carry memberId, so every top-up was checked against the member's MAIN position (Jim Watts: every ad said 19 free). It now reads the ad's row. When the ad's position is short, the error names it and lists the member's other positions with their free credits; the dashboard offers to pay from the best one. Moving an ad settles any charges its old position already ran up (a burn on the old member id) before switching, so the new position only pays for views after the move. Weekly email: unspent credits are broken down by position with the advice to start a campaign from the largest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3006,7 +3006,8 @@ const server = http.createServer(async (req, res) => {
|
||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||
const memberId = await auth.refreshMemberId(s);
|
||||
const b = await readBody(req);
|
||||
const r = await ads.topUpCampaign(s.email, memberId, m[1], b.credits);
|
||||
const positions = [memberId, ...(await accounts.positions(s.email).catch(() => [])).map(x => x.memberId)].filter(Boolean);
|
||||
const r = await ads.topUpCampaign(s.email, memberId, m[1], b.credits, { positions, switchTo: Number(b.switchTo) || 0 });
|
||||
return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
m = /^\/api\/my\/campaigns\/(\d+)\/extend$/.exec(p); // featured links: book more days (flat, charged now)
|
||||
|
||||
Reference in New Issue
Block a user