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:
@@ -227,7 +227,11 @@ async function record(p) {
|
||||
if (!out.repeat && out.badges && X.badge) for (const b of out.badges) { try { await X.badge(email, b); } catch (e) { console.error('refuel badge', e.message); } }
|
||||
// one short line in the payments feed for every counted refuel (never a Pit Stop), once per tx across app copies
|
||||
if (!out.repeat && out.kind === 'refuel' && X.feed && (!X.marks || await X.marks.claim('rffeed:' + tx))) {
|
||||
try { await X.feed(await feedLine(email, out)); } catch (e) { console.error('refuel feed', e.message); }
|
||||
// every counted refuel gets a card with the member's name and streak month (Marty 2026-11-24: "others need to see
|
||||
// that they're doing it"); the plain line is the fallback when the card cannot be drawn or sent
|
||||
let carded = false;
|
||||
if (X.card) { try { carded = !!(await X.card(email, { who: await whoOf(email), month: out.month, both: !!out.both, site: out.site, siteName: NAME[out.site] })); } catch (e) { console.error('refuel card', e.message); } }
|
||||
if (!carded) { try { await X.feed(await feedLine(email, out)); } catch (e) { console.error('refuel feed', e.message); } }
|
||||
}
|
||||
// a counted refuel of $50+ (either site) earns a Downline Banners spot, paid by the company (Marty 2026-11-13), once per tx
|
||||
if (!out.repeat && out.kind === 'refuel' && cents >= 5000 && X.refuelSpot && (!X.marks || await X.marks.claim('rfspot:' + tx))) {
|
||||
@@ -242,6 +246,14 @@ async function whoOf(email) {
|
||||
let a = null; try { a = await X.accounts.byEmail(email); } catch (e) {}
|
||||
return a && a.username ? '@' + a.username : a && a.memberId ? 'member #' + a.memberId : 'a member';
|
||||
}
|
||||
// admin: post the Refueled card for a member's CURRENT streak (a refuel counted before the card existed, or a resend)
|
||||
async function cardNow(email, o) {
|
||||
email = String(email || '').toLowerCase(); o = o || {};
|
||||
const rec = await getRec(email); if (!rec || !rec.active || !rec.streak) return { error: 'That member has no active refuel streak.' };
|
||||
if (!X.card) return { error: 'No card sender.' };
|
||||
const site = o.site === 'linkspin' ? 'linkspin' : 'iap';
|
||||
return { ok: !!(await X.card(email, { who: await whoOf(email), month: rec.streak, both: !!o.both, site, siteName: NAME[site] })), month: rec.streak };
|
||||
}
|
||||
async function feedLine(email, out) {
|
||||
const who = (await whoOf(email)).replace(/[<>&]/g, '');
|
||||
const what = out.both ? 'refueled both engines' : 'refueled ' + NAME[out.site];
|
||||
@@ -430,5 +442,5 @@ async function stats() {
|
||||
recent: rows.slice(0, 40).map(r => ({ ref: r.ref, site: r.site, email: r.email, kind: r.kind === 'grant' ? r.payload.kind : 'reminder:' + r.payload.remind, credits: r.payload.credits || 0, status: r.status, at: r.created })) };
|
||||
}
|
||||
|
||||
module.exports = { standing, setGoal, init, cfg, record, roundup, weekOf, feedLine, onIapPurchase, decide, settle, blank, view, streakLine, badgesOf, outbox, ack, drainLocal, tick, stats, reminderCopy,
|
||||
module.exports = { standing, setGoal, init, cfg, record, roundup, weekOf, feedLine, cardNow, onIapPurchase, decide, settle, blank, view, streakLine, badgesOf, outbox, ack, drainLocal, tick, stats, reminderCopy,
|
||||
_days: { ctDay, addDays, diffDays, label, ctHour }, SINGLE, BOTH };
|
||||
|
||||
Reference in New Issue
Block a user