Refuel Kit on LinkSpin (Fuel Your Offers stage 3, Marty approved 2026-10-24): kit.js (same file as InstantAdPay) with LinkSpin's own art, entitlement from InstantAdPay's streak record through refuel.status (view.kits: month -> streak month at unlock). Ads screen Refuel Kit panel (fuel.js?v=20261024kit): Make mine, Download, Copy image link, animated at a 3-month streak, and "Load into my Banner Spin" (kitspin.js): each Banner Spin size in the kit goes into one of the member's Banner Spins of that size with room, or a new one while the tier allows (the reason is shown when it does not); the personalized file is copied into uploads like a normal Banner Spin upload, labelled "Refuel Kit <month>", target = the member's own link; loading twice adds nothing twice; files over 150 KB are refused plainly. /kitimg/<hmac> public serving, admin Settings > Refuel Kit (upload, placeholder art, preview, release), raster copies of the LinkSpin placeholder banners (public/banners/linkspin-<size>.png, from the existing SVGs) for the placeholder kit. Behind the refuelStreak switch. Chatbot CANNED + FACTS mention the kit. qa/refuel-kit.test.cjs 5 checks against the real bannerspin.js. Note: qa kb retrieval has 2 pre-existing misses (spin links vs Banner Spin, PropellerAds postback), same before this change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
// "Load into my Banner Spin" for the Refuel Kit (2026-10-24). Each Banner Spin size in an unlocked kit goes into one of the
|
||||
// member's Banner Spins of that size that has room, or into a new Banner Spin when the member's tier allows one more.
|
||||
// The banner is the member's own personalized file (copied into uploads like a normal Banner Spin upload, so health checks,
|
||||
// moderation and Member content treat it the same), labelled "Refuel Kit <month>", the target their own link.
|
||||
// Loading the same kit twice does not add it twice.
|
||||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
|
||||
async function load(d) { // { kit, bannerspin, content, uploadsDir, email, month, variant, sizes }
|
||||
const { kit, bannerspin, email, month } = d;
|
||||
const mk = await kit.myKits(email); const k = mk.on && mk.kits.find(x => x.month === month);
|
||||
if (!k) return { error: 'No such kit.' };
|
||||
if (!k.unlocked) return { error: 'Your next counted refuel unlocks this kit.' };
|
||||
const t = await bannerspin.tierFor(email); if (!t.ok) return { error: t.reason, status: 403 };
|
||||
const want = Array.isArray(d.sizes) && d.sizes.length ? d.sizes.map(String) : k.sizes.filter(x => x.ready).map(x => x.size);
|
||||
const label = 'Refuel Kit ' + month; const results = [];
|
||||
for (const size of want.filter(z => bannerspin.SIZES[z] && k.sizes.some(x => x.size === z && x.ready))) {
|
||||
const mine = await bannerspin.list(email);
|
||||
const has = mine.find(x => x.size === size && x.banners.some(b => b.label === label));
|
||||
if (has) { results.push({ size, spinId: has.id, spin: has.name, already: true }); continue; }
|
||||
const r = await kit.renderFor(email, month, size, d.variant === 'gif' && k.gif ? 'gif' : 'still');
|
||||
if (r.error) { results.push({ size, error: r.error }); continue; }
|
||||
if (r.bytes > bannerspin.MAX_BYTES) { results.push({ size, error: 'The ' + size + ' file is over 150 KB, so Banner Spin cannot take it. Use the still version.' }); continue; }
|
||||
let spin = mine.find(x => x.size === size && x.banners.length < t.banners && !x.adminOff), created = false;
|
||||
if (!spin) { const c = await bannerspin.create(email, { name: 'Refuel Kit ' + size, size, fallback: mk.link || '' }); if (c.error) { results.push({ size, error: c.error }); continue; } spin = c.spin; created = true; }
|
||||
const name = crypto.randomBytes(12).toString('hex') + '.' + r.ext;
|
||||
fs.writeFileSync(path.join(d.uploadsDir, name), fs.readFileSync(r.file));
|
||||
const mime = { png: 'image/png', jpg: 'image/jpeg', gif: 'image/gif' }[r.ext];
|
||||
try { if (d.content) d.content.noteUpload(name, email, r.bytes, mime, ''); } catch (e) {}
|
||||
bannerspin.noteImage(email, name, r.w, r.h, r.bytes, mime);
|
||||
const add = await bannerspin.addBanner(email, spin.id, { image: '/uploads/' + name, target: mk.link, label });
|
||||
results.push(add.error ? { size, error: add.error } : { size, spinId: spin.id, spin: spin.name, created });
|
||||
}
|
||||
return { ok: true, results };
|
||||
}
|
||||
module.exports = { load };
|
||||
Reference in New Issue
Block a user