Ad editing: fix the link, image, text or name of a running ad; first edit free, then campaignEditFee credits
Orlando (#30) could only pause, resume or top up a banner or login ad with a wrong link. - POST /api/my/campaigns/<id>/edit (owner) and /api/admin/campaigns/<id>/edit (any ad, free, never uses the member's free edit). Banner: link, image, name. Text: link, headline, line, name. Login and the rest: link, name. Type, size, budget, geo, schedule, audience are refused. - Create and edit share one path: checkName/checkTarget/checkBannerImage/checkTextCopy in ads.js (validate() now calls them) and adChecks() in server.js (frame check + a new banner image check: loads, is a real PNG/JPG/GIF/WebP, up to 3 MB; own uploads read off the volume). - Fee: campaigns.edits counts member edits; the first is free, each later one costs the site setting campaignEditFee (default 100, admin Settings). Charged from the engine pool via spendEarned (earned first, then credited purchased); with neither, a burn row on the best-funded position (the normal burn queue). Guarded claim so two saves cannot both be free; a failed save refunds exactly what was taken. - History: campaigns.edit_log (ts, by, fields, old/new values, fee), last 50. - NAS: clicks already route through /api/ads/click/<id>, so a new link needs no write; a new image or text goes to the NAS row via nas.updateCreative. Failures never block the edit and retry on the next reconcile pass. Open ad-viewer tokens get the new link. - UI: Edit button on the Ads screen (CR.dialog editor, real-size preview, upload, free/fee note and confirm), /ads#edit=<id> deep link from the /tools list, admin Member content shows edit count + history with an Edit action. Chatbot canned answer + FACTS. - qa/adedit.mjs: 51 checks against a throwaway DATA_DIR, Playwright screenshots in D:/tmp/ad-edit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,14 @@ async function setClickUrl(nasAdId, campaignId) {
|
||||
await q('UPDATE sponsorads SET WebsiteURL=? WHERE ID=?', [SITE_URL + '/api/ads/click/' + Number(campaignId), Number(nasAdId)]);
|
||||
return { ok: true };
|
||||
}
|
||||
// an edited campaign's creative (2026-10-18): headline, text line and banner image on the live NAS row.
|
||||
// The click URL never changes (it is our /api/ads/click/<id> redirect), so a new link needs no NAS write.
|
||||
async function updateCreative(nasAdId, c) {
|
||||
if (!enabled()) return { skipped: 'flag-off' };
|
||||
if (c.type === 'banner') await q('UPDATE sponsorads SET BannerURL=?, Subject=? WHERE ID=?', [c.imageUrl || null, c.title || null, Number(nasAdId)]);
|
||||
else if (c.type === 'text') await q('UPDATE sponsorads SET Subject=?, Body=? WHERE ID=?', [c.title || null, c.body || null, Number(nasAdId)]);
|
||||
return { ok: true };
|
||||
}
|
||||
async function topUp(nasAdId, addImpressions, days) {
|
||||
if (!enabled()) return { skipped: 'flag-off' };
|
||||
await q(`UPDATE sponsorads SET assigned=assigned+?, remaining=remaining+?, approved=1,
|
||||
@@ -123,4 +131,4 @@ async function topUp(nasAdId, addImpressions, days) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
module.exports = { setClickUrl, enabled, pushCampaign, readServed, deactivate, topUp, impressionsPerCredit, nasKind };
|
||||
module.exports = { setClickUrl, updateCreative, enabled, pushCampaign, readServed, deactivate, topUp, impressionsPerCredit, nasKind };
|
||||
|
||||
Reference in New Issue
Block a user