Friday Bonus Hunts: InstantAdPay counts the banked days

Each day Saturday through Thursday (Central) that a member opens an inbox ad
and watches a video banks one extra PolHunter hunt for the following Friday.
If their inbox had no unread solo ad that day, the video alone counts, so
nobody is blocked by an empty inbox. These are the two slowest-delivering ad
types (about 6-7 views per campaign per day against 40-50 for banners), so
the game sends attention exactly where advertisers are short of it.

fridaybank.js counts from video_seen and solo_inbox.read_ts with DST-safe
Central midnights. /api/my/friday-bank feeds a card on the Earn tab (week
chips, today's two steps with links to the right sub-tab);
/api/hunt/friday-bank answers PolHunter, HMAC-signed with the existing
HUNT_SSO_SECRET, 5-minute window. QA member walk: 0 bugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-26 15:20:51 -05:00
parent 9116368ffe
commit cf5a9674a2
4 changed files with 125 additions and 1 deletions
+20
View File
@@ -45,6 +45,7 @@ const leaderboard = require('./leaderboard');
const toolkit = require('./toolkit');
const badge = require('./badge'); // achievement badge image drawn on the server with ffmpeg (2026-09-16)
const friday = require('./friday');
const fridaybank = require('./fridaybank'); // Friday Bonus Hunts: days banked Sat-Thu by solo + video (2026-09-26)
const refill = require('./refill'); // campaign running-low / ran-out notices, and what came of them // Five Dollar Friday: +20% credits on Friday packs, the wave, the badge (Marty, 2026-09-20)
const snapshot = require('./snapshot'); // daily growth snapshot -> Telegram payments feed (Marty, 2026-09-15)
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
@@ -471,6 +472,7 @@ async function boot() {
snapshot.init({ dataDir: DATA_DIR, db, chain, siteConfig, publicDir: PUBLIC_DIR,
send: async (c, t, th) => { await telegramSend(c, t, th); return true; },
sendPhoto: (c, jpeg, cap, th) => telegramSendPhoto(c, jpeg, cap, th) });
fridaybank.init({ db });
friday.init({ dataDir: DATA_DIR, siteConfig, chain, ads, accounts, mailer, drip, marks,
telegram: 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); },
notify: async (memberId, subject, text, kind) => { const a = await accounts.byMemberId(memberId); if (!a || !a.email) return; const html = '<p>' + String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(https:\/\/[^\s]+)/g, '<a href="$1" target="_blank" rel="noopener">$1</a>').split('\n\n').join('</p><p>').replace(/\n/g, '<br>') + '</p>'; await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [a.email], subject, html, kind || 'notice'); } });
@@ -2316,6 +2318,24 @@ const server = http.createServer(async (req, res) => {
earnTokens.delete(s.email); // single use
return json(res, 200, await ads.recordView(s.email));
}
// -- Friday Bonus Hunts (2026-09-26). The member's own progress, for the Earn tab card.
if (p === '/api/my/friday-bank' && req.method === 'GET') {
const s = await auth.fromRequest(req);
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
return json(res, 200, await fridaybank.bankFor(s.email));
}
// PolHunter asks, server to server, signed with the same shared secret as the hand-off:
// sig = HMAC-SHA256(HUNT_SSO_SECRET, 'fridaybank:' + email + ':' + ts), ts within 5 minutes.
if (p === '/api/hunt/friday-bank' && req.method === 'GET') {
const secret = String(process.env.HUNT_SSO_SECRET || '').trim();
if (secret.length < 32) return json(res, 503, { error: 'not connected' });
const q = new URL(req.url, 'http://x').searchParams;
const email = String(q.get('email') || '').trim().toLowerCase(), ts = Number(q.get('ts') || 0), sig = String(q.get('sig') || '');
if (!email || !ts || Math.abs(Date.now() - ts) > 300000) return json(res, 400, { error: 'stale or missing' });
const want = crypto.createHmac('sha256', secret).update('fridaybank:' + email + ':' + ts).digest('hex');
if (sig.length !== want.length || !crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(want))) return json(res, 401, { error: 'bad signature' });
return json(res, 200, await fridaybank.bankFor(email));
}
// -- PolHunter hand-off (2026-09-19): sign the member across; polhunter.com verifies with the shared secret
if (p === '/api/my/polhunter' && req.method === 'GET') {
const s = await auth.fromRequest(req);