One swap per banner + admin takedown (Marty 2026-11-15: "allow the member to swap it only, and they can only do it one time. Admin takes down the option to credit back or none.")

Member swap: My Banners shows "Swap image or link" on a banner that is waiting or in the loop, usable once (then "Swap used"). POST /api/my/banners/<id>/swap changes the image and/or link (or a Banner Spin to another of the member's own 125x125/250x250 spins via lsspins), same checks as a new post (checkLink, probeLink, upload/https image checks); id, place, clicks and loop progress stay. Logged on the banner (swaps: old/new image + link, time). No withdraw, removal or refund for members.

Admin takedown: /admin finds banners (#id, wallet, username), POST /api/admin/banners/<id>/takedown {reason required, credit: back|none}. The banner is hidden at once (splash loop + waiting line show a house tile in its place, /go goes home, no look/teaser/swap); its place rides out on time so nobody moves, then it ends with no cycle, no network views, no prize count. My Banners shows "Taken down" with the reason. Restore reverses a given credit (when the owner still holds one) and, if its place rode out meanwhile, records the cycle then. Admin ledger: GET /api/admin/actions (who, when, reason, credit decision).

Chatbot: CANNED 'swap' + FACTS line (KNOWLEDGE_DATE already 2026-11-15), chat-qa entry. my.js?v=4, admin.js?v=3, vbb.css?v=8.
Tests: smoke section 15 (swap once, refused twice, keeps place, bad link/image refused, spin swap, takedown credit back vs none, others keep places, ride-out without a cycle, restore, admin ledger, phone UI): 308/308 with the committed networksso.js; chatbot.test 182/182; qa:chain 49/49.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 15:18:49 -06:00
parent 666cdd9569
commit 8e6d2f9cd0
11 changed files with 409 additions and 28 deletions
+17 -3
View File
@@ -23,10 +23,16 @@ function enter(id) {
}
function cycleOut(id) {
const b = store.banner(id); if (!b) return null;
// taken down by the admin (Marty 2026-11-15): its place rode out on time, but it never cycles and never earns
if (b.down) { b.state = 'ended'; b.endedAt = Date.now(); store.saveBanner(b); return null; }
b.state = 'cycled'; b.cycledAt = Date.now(); store.saveBanner(b);
return recordCycle(b);
}
// the cycle reward: one ledger row (also used when the admin restores a banner whose place rode out while it was taken down)
function recordCycle(b, extra) {
const S = store.state(); S.totals.cycles++; S.totals.views += C().viewsPerCycle; store.bump('cycles');
const m = store.member(b.owner);
const e = store.addLedger({ bannerId: b.id, owner: b.owner, username: (m && m.username) || null, views: C().viewsPerCycle, day: store.ctDay(), status: 'recorded' });
const e = store.addLedger(Object.assign({ bannerId: b.id, owner: b.owner, username: (m && m.username) || null, views: C().viewsPerCycle, day: store.ctDay(), status: 'recorded' }, extra || {}));
if (onCycle) try { onCycle(b, e); } catch (x) {}
return e;
}
@@ -118,7 +124,9 @@ function memberWeek(addr) {
// ---- views for pages ----
// the banner look (bought per banner, SKU 3): a highlighted border and a hover teaser (the member's line, else the link's site)
const hostOf = l => { try { return new URL(l).hostname.replace(/^www\./, ''); } catch (e) { return ''; } };
function tile(b) { const m = store.member(b.owner); const t = { id: b.id, img: b.img, href: '/go/' + b.id, owner: (m && m.username) ? '@' + m.username : null };
// a banner the admin took down keeps its place (nobody else moves) but shows as a house tile: no image, owner, link or id of its own
const houseTile = b => ({ id: 'h' + b.id, house: true, img: '/art/tile-house.svg', href: '/my', owner: null });
function tile(b) { if (b.down) return houseTile(b); const m = store.member(b.owner); const t = { id: b.id, img: b.img, href: '/go/' + b.id, owner: (m && m.username) ? '@' + m.username : null };
if (b.spin) t.spin = true;
if (b.look) { t.look = true; t.teaser = b.teaser || (b.spin && b.spin.name) || hostOf(b.link); } return t; }
function view(queueShow) {
@@ -135,5 +143,11 @@ function placeOf(b) {
if (b.state === 'loop') { const i = S.loop.indexOf(b.id); return { state: 'loop', place: i + 1, of: C().loopSize, shiftsToRideOut: Math.max(1, C().loopSize - i) }; }
return { state: b.state };
}
// a member-facing place: a taken-down banner says so (with the admin's reason), whatever its slot is doing
function memberPlace(b) {
const p = placeOf(b);
if (!b.down) return p;
return { state: 'down', slot: p.state, downAt: b.down.at, downReason: b.down.reason, creditBack: !!b.down.creditBack };
}
module.exports = { hostOf, init, post, shift, verifiedVisit, canCount, rebuildIndex, leaders, memberWeek, view, placeOf, normalize };
module.exports = { hostOf, init, post, shift, verifiedVisit, canCount, rebuildIndex, leaders, memberWeek, view, placeOf, memberPlace, recordCycle, normalize };