BTC4Hits import, round 2: tank cap 10 at one time (setting tankAdoptCap) with tests; BTC4Hits origin kept on carried shells (joinedRef btc4hits) and the adoption note/email/auto-assign message say their BTC4Hits account moved here; imported spin links may carry every valid URL (admin route maxDests up to 2000, one save per batch), editor shows 50 rows of a big link with Show all, Check now runs in the background past 50, at most one pause email per link per day; chatbot knows /from/btc4hits + the cap (KNOWLEDGE_DATE 2026-11-11). qa: tank-cap 15/15, tank-hold all passed, btc4hits-bridge 21/21, sponsorfollow 30/30

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Marty Bostick
2026-11-11 08:08:58 -06:00
parent f811ee2e8c
commit 5d79abe318
9 changed files with 105 additions and 19 deletions
+8 -3
View File
@@ -130,13 +130,18 @@ async function update(owner, id, body) {
J.save(); return { ok: true, rotation: pub(r) };
}
async function remove(owner, id) { const n = J.db.rotations.length; J.db.rotations = J.db.rotations.filter(r => !(r.id === Number(id) && r.owner === norm(owner))); J.save(); return n !== J.db.rotations.length ? { ok: true } : { error: 'No such rotation.' }; }
async function addDest(owner, id, body) {
// opts.max: the admin import path only (BTC4Hits rotators, 2026-11-11) may go past the 25 a member can add, up to IMPORT_MAX
const DEST_MAX = 25, IMPORT_MAX = 2000;
async function addDest(owner, id, body, opts) {
const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); if (!r) return { error: 'No such rotation.' };
const url = cleanUrl(body.url); if (!url) return { error: 'Destination must be a full https:// address.' };
if (r.destinations.length >= 25) return { error: 'Up to 25 destinations per rotation.' };
const cap = opts && opts.max ? Math.min(IMPORT_MAX, Math.max(DEST_MAX, Math.round(Number(opts.max) || DEST_MAX))) : DEST_MAX;
if (r.destinations.length >= cap) return { error: 'Up to ' + DEST_MAX + ' destinations per rotation.' };
const w = Math.max(1, Math.min(100, Math.round(Number(body.weight) || 1)));
const d = { id: r.nextDest++, url, label: String(body.label || '').trim().slice(0, 60), weight: w, active: true, added: Date.now() };
r.destinations.push(d); J.save(); return { ok: true, rotation: pub(r) };
r.destinations.push(d);
if (opts && opts.defer) return { ok: true, id: d.id }; // bulk import: the caller saves once at the end (rotator.json holds every click, ~18 MB; one write per destination would stall the app)
J.save(); return { ok: true, rotation: pub(r) };
}
async function updateDest(owner, id, did, body) {
const r = J.db.rotations.find(r => r.id === Number(id) && r.owner === norm(owner)); if (!r) return { error: 'No such rotation.' };