Refueled card: every counted Monthly Refuel posts a card with the member's name and streak month to the payments topic and General (plain line stays as the fallback); admin POST /api/admin/refuel/card posts one for a member's current streak (Marty 2026-11-24)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -747,6 +747,21 @@ async function boot() {
|
||||
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [to], subject, html, 'notice'); },
|
||||
badge: (email, key) => postBadgeOnce(email, key, 'Monthly Refuel'),
|
||||
refuelSpot: refuelSpotToBL, // $50+ counted refuel -> one Downline Banners spot (2026-11-13)
|
||||
// the Refueled card: payments topic + General, like a badge. Returns false when nothing went out (refuel.js then posts the plain line)
|
||||
card: async (email, r) => {
|
||||
const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false;
|
||||
const a = await accounts.byEmail(String(email || '').toLowerCase()).catch(() => null);
|
||||
const name = a && a.username ? a.username : (a && a.memberId ? 'member #' + a.memberId : 'a member');
|
||||
const jpeg = await badge.render('refuelCard', name, [{ text: 'STREAK MONTH ' + r.month, y: 0.662, size: 62 }, { text: r.both ? 'Both engines: InstantAdPay + LinkSpin' : 'Refueled on ' + r.siteName, y: 0.722, size: 32, color: '#bff5dc' }]);
|
||||
if (!jpeg) return false;
|
||||
const who = String(r.who || name).replace(/[<>&]/g, '');
|
||||
const caption = '⛽ <b>InstantAdPay</b> · <b>' + who + '</b> ' + (r.both ? 'refueled both engines' : 'refueled ' + r.siteName) + ' · streak month ' + r.month + '\n' + (a && a.username ? 'instantadpay.com/join/' + a.username : 'instantadpay.com');
|
||||
let sent = 0;
|
||||
if (await telegramSendPhoto(sc.telegramEchoChatId, jpeg, caption, sc.telegramEchoTopicId)) sent++;
|
||||
if (String(sc.telegramBadgeGeneral || '1') !== '0' && await telegramSendPhoto(sc.telegramEchoChatId, jpeg, caption, null)) sent++;
|
||||
console.log('refuel card', name, 'month', r.month, 'sent', sent);
|
||||
return sent > 0;
|
||||
},
|
||||
feed: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false; return telegramSend(sc.telegramEchoChatId, '\u{1F7E0} <b>InstantAdPay</b> \u00b7 ' + text, sc.telegramEchoTopicId); } });
|
||||
kit.init({ dataDir: DATA_DIR, program: 'iap', publicDir: PUBLIC_DIR, siteUrl: 'https://instantadpay.com',
|
||||
entitled: async email => { const v = await refuel.view(email); return v && v.on ? { on: true, months: v.kits || {}, nextRefuel: v.refuelDayLabel || null, today: v.today || null } : { on: false }; },
|
||||
@@ -6101,6 +6116,11 @@ const server = http.createServer(async (req, res) => {
|
||||
if (r.error) return json(res, 400, r);
|
||||
res.writeHead(200, { 'Content-Type': { png: 'image/png', jpg: 'image/jpeg', gif: 'image/gif' }[r.ext], 'Cache-Control': 'no-store' }); return fs.createReadStream(r.file).pipe(res);
|
||||
}
|
||||
if (p === '/api/admin/refuel/card' && req.method === 'POST') { // post the Refueled card for a member's current streak (2026-11-24)
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const b = await readBody(req); const r = await refuel.cardNow(b.email, { both: !!b.both, site: b.site });
|
||||
return json(res, r.error ? 400 : 200, r);
|
||||
}
|
||||
if (p === '/api/admin/refuel' && req.method === 'GET') { // Monthly Refuel: settings, members on a streak, grants by kind, recent outbox rows
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
return json(res, 200, await refuel.stats());
|
||||
|
||||
Reference in New Issue
Block a user