AI ad writer on text-ad campaigns (Marty 2026-11-17: "do it on the other sites too"): "Write my ad from my link" under the text ad fields asks the network hub (hubadwriter.js, POST /v1/adwriter, headline 60 / ad text 140) for 3 ads from the Target URL; GET/POST /api/my/adwriter; shown only when the hub says on; chatbot fact, KNOWLEDGE_DATE 2026-11-17; my.js?v=20261117aiw. iap-qa member 0 bugs, kb green

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-17 08:16:39 -06:00
parent 218bb10145
commit d471a5664d
6 changed files with 138 additions and 2 deletions
+14
View File
@@ -60,6 +60,7 @@ const tankbatch = require('./tankbatch'); // holding tank batches (2026-11-15):
const draftpartner = require('./draftpartner'); // 5xYourTeam The Draft: signed pool / adopt / release / status on the network tank (2026-11-15, needs DRAFT_PARTNER_SECRET)
const loginClock = require('./loginadclock'); // login ads on a clock, not only at sign-in (Marty 2026-11-15): see loginadclock.js
const erase = require('./erase'); // member erase (2026-11-15, LS-1021): POST /api/admin/erase + the hub's member.erased event
const adwriter = require('./hubadwriter'); // the network AI ad writer, asked through the hub (2026-11-17): text-ad campaigns
const hubsync = require('./hubsync'); // network hub: members from other doors arrive as waiting accounts, ours are reported (2026-11-12, only with HUB_ENABLED)
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to LinkSpin until chain-bound + one network tank (2026-10-22)
const bixpay = require('./bixpay'); // BixPay Visa card: partner-link field, sponsor-follows resolver, tracked clicks (2026-10-29, gated by site config bixpayLive)
@@ -5748,6 +5749,19 @@ const server = http.createServer(async (req, res) => {
out.loginLine = await ads.loginQueueView(s.email); // login-ad slots: open now, the paid line, this member's places + estimated starts
return json(res, 200, out);
}
// the AI ad writer (Marty 2026-11-17: "do it on the other sites too"): the hub reads the member's target page and suggests 3
// text ads (headline 60, ad text 140) written only from it. Nothing is created here: the member picks one, edits it, creates the campaign.
if (p === '/api/my/adwriter' && (req.method === 'GET' || req.method === 'POST')) {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
if (req.method === 'GET') { const w = await adwriter.status(s.email); return json(res, 200, { on: !!w.on, daily: w.daily || 0, left: w.left }); }
if (!(await adwriter.enabled())) return json(res, 503, { error: 'The ad writer is switched off right now. You can still write your ad yourself.' });
if (supportFlood('aiw:' + clientIp(req), 12, 3600000)) return json(res, 429, { error: 'Too many ad writes from this connection this hour. Try again later, or write your ad yourself.' });
const b = await readBody(req);
const r = await adwriter.write(s.email, String((b && b.url) || '').trim().slice(0, 600), { headline: 60, line: 140 });
if (r.error) return json(res, r.status || 400, { error: r.error, code: r.code, left: r.left });
return json(res, 200, { ok: true, options: r.options, url: r.url, cached: r.cached, left: r.left });
}
if (p === '/api/my/campaigns' && req.method === 'POST') {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });