Short banner image URLs (Michael Camire via Marty, 2026-11-03): the Spaces CDN links in the Games and BixPay kits ran about 105 characters and exchange / safelist image fields cut them off, so the banners never showed. /b/<slug>/<file> on instantadpay.com and the share hosts (https://ctbgo.com/b/turkeydrop/728x90.png) serves the same game-banners CDN file in place (no redirect, HEAD works, 300-file six-hour cache); promo.js builds every game and BixPay banner URL on the share domain; chatbot banner-image answer; promo.js?v=20261103b, KNOWLEDGE_DATE 2026-11-03

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-03 07:36:55 -06:00
parent c0a435343a
commit 7d28ec7b5f
4 changed files with 48 additions and 10 deletions
+35
View File
@@ -2200,11 +2200,46 @@ async function gameAnswer(g, slug, acct) { // the game token (only once a userna
}
const SHARE_HOSTS = String(process.env.SHARE_HOSTS || 'ctbgo.com,mylinehq.com').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
// Short banner image URLs (2026-11-03; Michael Camire via Marty: the Spaces CDN URLs run about 105 characters and get cut off
// by exchange and safelist image fields, so the banners never show). /b/<slug>/<file> serves the same file from
// game-banners/<slug>/ on the Spaces CDN, bytes in place (no redirect: some sites only HEAD the URL), on the share hosts as
// well as here: https://ctbgo.com/b/turkeydrop/728x90.png. A bare <size>.<ext> expands to <slug>-<size>.<ext>. Small
// in-memory cache, 300 files, six hours, misses remembered ten minutes.
const BANNER_CDN = 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/';
const BANNER_TYPES = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp', gif: 'image/gif' };
const bannerCache = new Map(); // cdn url -> { buf, type, at, miss }
async function serveBanner(req, res, p) {
const m = /^\/b\/([a-z0-9-]{2,30})\/([a-z0-9-]{1,60})\.(png|jpe?g|webp|gif)$/i.exec(p);
if (!m) return false;
const slug = m[1].toLowerCase(), ext = m[3].toLowerCase();
let name = m[2].toLowerCase(); if (/^\d{2,4}x\d{2,4}$/.test(name)) name = slug + '-' + name;
const url = BANNER_CDN + slug + '/' + name + '.' + ext;
let hit = bannerCache.get(url);
if (!hit || Date.now() - hit.at > (hit.miss ? 600e3 : 6 * 3600e3)) {
try {
const r = await fetch(url, { signal: AbortSignal.timeout(10000) });
if (r.ok) {
const buf = Buffer.from(await r.arrayBuffer());
hit = { buf, type: r.headers.get('content-type') || BANNER_TYPES[ext], at: Date.now() };
} else hit = { miss: r.status, at: Date.now() };
if (bannerCache.size >= 300) bannerCache.delete(bannerCache.keys().next().value);
bannerCache.set(url, hit);
} catch (e) { if (!hit) { res.writeHead(502, baseHeaders({ 'Content-Type': 'text/plain', 'Cache-Control': 'no-store' })); res.end('banner source unreachable'); return true; } }
}
if (hit.miss) { res.writeHead(404, baseHeaders({ 'Content-Type': 'text/plain', 'Cache-Control': 'no-store' })); res.end('no such banner'); return true; }
res.writeHead(200, baseHeaders({ 'Content-Type': hit.type, 'Content-Length': hit.buf.length, 'Cache-Control': 'public, max-age=86400', 'Access-Control-Allow-Origin': '*', 'X-Robots-Tag': 'noindex' }));
if (req.method === 'HEAD') res.end(); else res.end(hit.buf);
return true;
}
const server = http.createServer(async (req, res) => {
{ const t0 = Date.now(); res.on('finish', () => { const ms = Date.now() - t0; if (ms > 3000) console.warn('slow request', req.method, String(req.url || '').split('?')[0].slice(0, 80), ms + 'ms', res.statusCode); }); } // visibility for member-felt delays (2026-10-12)
try {
const u = new URL(req.url, 'http://x');
const p = u.pathname;
// short banner images, served on every host (share hosts included) before the share-host redirect
if ((req.method === 'GET' || req.method === 'HEAD') && p.startsWith('/b/') && await serveBanner(req, res, p)) return;
// share-link domains (ctbgo.com, mylinehq.com): /<ref> goes to that member's join page, anything else to the same path
// here. 302 (not 301) so links never get pinned in caches; the query (?v= angle, ?promo=) rides along.
{ const sh = String(req.headers.host || '').toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');