Friday Bonus Hunts: extra Friday hunts banked on InstantAdPay
lib/fridaybank.js asks InstantAdPay (HMAC with HUNT_SSO_SECRET, 3-minute cache) how many days Sat-Thu the hunter opened an inbox ad and watched a video. On Friday that many extra hunts are added to the daily limit, capped at live missions minus the normal three so every bonus has a mission to hunt. If InstantAdPay can't be reached the bonus is 0: it never grants hunts it could not verify. The board shows the week's chips and today's steps; the done-for- today overlay now points at banking. dailyMsg counts past five. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
// Friday Bonus Hunts, PolHunter side (Marty, 2026-09-26).
|
||||||
|
//
|
||||||
|
// InstantAdPay counts the days (Saturday through Thursday, Central) on which a hunter opened an
|
||||||
|
// inbox ad and watched a video there; each such day banks one extra hunt, usable ONLY on the
|
||||||
|
// Friday that follows. This module asks InstantAdPay for that count, signed with the same
|
||||||
|
// shared secret as the sign-in hand-off, and turns it into today's bonus.
|
||||||
|
//
|
||||||
|
// Usable bonus = banked, capped at (live missions - the normal daily limit): every mission can be
|
||||||
|
// found once a day, so a bonus larger than the missions left would be a promise with nothing to
|
||||||
|
// hunt. With 8 missions and 3 a day that cap is 5; it rises on its own as missions are added.
|
||||||
|
//
|
||||||
|
// Failure is safe in one direction only: if InstantAdPay can't be reached, the bonus is 0 and the
|
||||||
|
// hunter keeps their normal missions. It never grants hunts it could not verify.
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const https = require('https');
|
||||||
|
const IAP = String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '');
|
||||||
|
const cache = new Map(); // email -> { at, data }
|
||||||
|
const TTL = 3 * 60 * 1000;
|
||||||
|
|
||||||
|
function fetchJson(url) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const rq = https.get(url, { timeout: 8000 }, r => {
|
||||||
|
let raw = ''; r.setEncoding('utf8'); r.on('data', d => { raw += d; });
|
||||||
|
r.on('end', () => { try { resolve(r.statusCode === 200 ? JSON.parse(raw) : null); } catch (e) { resolve(null); } });
|
||||||
|
});
|
||||||
|
rq.on('timeout', () => { rq.destroy(); resolve(null); });
|
||||||
|
rq.on('error', () => resolve(null));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function bankFor(email) {
|
||||||
|
const e = String(email || '').trim().toLowerCase();
|
||||||
|
const secret = String(process.env.HUNT_SSO_SECRET || '').trim();
|
||||||
|
if (!e || secret.length < 32) return null;
|
||||||
|
const hit = cache.get(e);
|
||||||
|
if (hit && Date.now() - hit.at < TTL) return hit.data;
|
||||||
|
const ts = Date.now();
|
||||||
|
const sig = crypto.createHmac('sha256', secret).update('fridaybank:' + e + ':' + ts).digest('hex');
|
||||||
|
const data = await fetchJson(IAP + '/api/hunt/friday-bank?email=' + encodeURIComponent(e) + '&ts=' + ts + '&sig=' + sig);
|
||||||
|
if (data && Array.isArray(data.days)) { cache.set(e, { at: Date.now(), data }); return data; }
|
||||||
|
if (hit) return hit.data; // a stale answer beats none for display
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// { banked, usable, bonus (today's extra hunts), isFriday, friday, today, days, cap }
|
||||||
|
async function forHunter(me, activeMissions, base) {
|
||||||
|
const b = await bankFor(me && me.email);
|
||||||
|
const cap = Math.max(0, Number(activeMissions || 0) - Number(base || 3));
|
||||||
|
if (!b) return { banked: 0, usable: 0, bonus: 0, isFriday: false, cap, available: false };
|
||||||
|
const usable = Math.min(b.banked, cap);
|
||||||
|
return { banked: b.banked, usable, bonus: b.isFriday ? usable : 0, isFriday: b.isFriday, friday: b.friday, today: b.today, days: b.days, cap, available: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { forHunter, bankFor };
|
||||||
+4
-2
@@ -35,11 +35,13 @@ function draw(min, max, skew) {
|
|||||||
// day defaults to today: called without it the comparison was against undefined and silently
|
// day defaults to today: called without it the comparison was against undefined and silently
|
||||||
// returned 0 for everyone, which would read as "no finds yet" to any new caller
|
// returned 0 for everyone, which would read as "no finds yet" to any new caller
|
||||||
function findsToday(memberId, day) { const d = day || ctDay(); return store.read('payouts', []).filter(p => p.memberId === Number(memberId) && p.day === d && p.status !== 'failed' && !p.prize && !p.ref).length; }
|
function findsToday(memberId, day) { const d = day || ctDay(); return store.read('payouts', []).filter(p => p.memberId === Number(memberId) && p.day === d && p.status !== 'failed' && !p.prize && !p.ref).length; }
|
||||||
function daily(memberId, doneIds) { const s = settings(); const base = Math.max(1, Number(s.missionsPerDay) || 3);
|
function daily(memberId, doneIds, bonus) { const s = settings(); const base = Math.max(1, Number(s.missionsPerDay) || 3);
|
||||||
// every live paid mission this hunter has not done yet adds one, because the company is not
|
// every live paid mission this hunter has not done yet adds one, because the company is not
|
||||||
// funding that completion
|
// funding that completion
|
||||||
let extra = 0; try { extra = require('./paid').extraAllowance(doneIds); } catch (e) {}
|
let extra = 0; try { extra = require('./paid').extraAllowance(doneIds); } catch (e) {}
|
||||||
const limit = base + extra; const done = findsToday(memberId, ctDay()); return { limit, done, left: Math.max(0, limit - done) }; }
|
// Friday Bonus Hunts: extra hunts banked Sat-Thu on InstantAdPay, usable on Friday only (lib/fridaybank.js)
|
||||||
|
const fb = Math.max(0, Number(bonus) || 0);
|
||||||
|
const limit = base + extra + fb; const done = findsToday(memberId, ctDay()); return { limit, done, left: Math.max(0, limit - done), base, friday: fb }; }
|
||||||
// What the COMPANY has spent today. Advertiser-funded completions are excluded on purpose: the
|
// What the COMPANY has spent today. Advertiser-funded completions are excluded on purpose: the
|
||||||
// hunter is paid out of what the advertiser already put in the faucet, so counting it here would
|
// hunter is paid out of what the advertiser already put in the faucet, so counting it here would
|
||||||
// let a paid mission use up the house budget (Marty, 2026-09-24).
|
// let a paid mission use up the house budget (Marty, 2026-09-24).
|
||||||
|
|||||||
+2
-1
@@ -19,6 +19,7 @@
|
|||||||
<h2>Your missions</h2>
|
<h2>Your missions</h2>
|
||||||
<div class="sub" id="rangeLine">Each find pays a random drip. Your codes are yours alone.</div>
|
<div class="sub" id="rangeLine">Each find pays a random drip. Your codes are yours alone.</div>
|
||||||
<div id="refSlot"></div>
|
<div id="refSlot"></div>
|
||||||
|
<div id="fbank" hidden style="margin:12px 0 16px;padding:14px 16px;border-radius:16px;border:1px solid var(--edge-hi);background:rgba(130,71,229,.12)"></div>
|
||||||
<div class="grid" id="missions"><div class="card"><p>Loading your board…</p></div></div>
|
<div class="grid" id="missions"><div class="card"><p>Loading your board…</p></div></div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -47,6 +48,6 @@
|
|||||||
<footer class="foot">Rewards are for completed missions, not income. The daily pool is limited; when it is spent, claims close until midnight Central. Cryptocurrency involves risk of loss.</footer>
|
<footer class="foot">Rewards are for completed missions, not income. The daily pool is limited; when it is spent, claims close until midnight Central. Cryptocurrency involves risk of loss.</footer>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal" id="shareModal" hidden><div class="modal-card"><button class="modal-x" id="shareClose" type="button" aria-label="Close">×</button><div id="shareBody"></div></div></div>
|
<div class="modal" id="shareModal" hidden><div class="modal-card"><button class="modal-x" id="shareClose" type="button" aria-label="Close">×</button><div id="shareBody"></div></div></div>
|
||||||
<script src="/app.js?v=18"></script>
|
<script src="/app.js?v=19"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+23
-1
@@ -149,6 +149,7 @@
|
|||||||
}
|
}
|
||||||
watchPaid(); if (seenLedger === null) watchLedger();
|
watchPaid(); if (seenLedger === null) watchLedger();
|
||||||
doneNudge(board.daily);
|
doneNudge(board.daily);
|
||||||
|
fridayCard(board.fridayBank);
|
||||||
const dl = board.daily; if (dl && $('rangeLine')) $('rangeLine').innerHTML = ($('rangeLine').textContent.replace(/\s*·\s*You have.*$/, '')) + ' \u00b7 ' + (dl.left ? 'You have <b>' + dl.left + ' of ' + dl.limit + '</b> missions left today.' : '<b>That is your ' + dl.limit + ' for today.</b> Fresh missions at midnight Central.');
|
const dl = board.daily; if (dl && $('rangeLine')) $('rangeLine').innerHTML = ($('rangeLine').textContent.replace(/\s*·\s*You have.*$/, '')) + ' \u00b7 ' + (dl.left ? 'You have <b>' + dl.left + ' of ' + dl.limit + '</b> missions left today.' : '<b>That is your ' + dl.limit + ' for today.</b> Fresh missions at midnight Central.');
|
||||||
$('mine').innerHTML = board.drips.length ? board.drips.map(d => '<div class="row"><span>' + esc(d.site) + '</span><span class="site">' + ({ paid: 'paid', sent: 'sending', due: 'paying next', queued: 'queued for the next pool', failed: 'held, being looked at' }[d.status] || d.status) + '</span><span class="pol">+' + d.pol + ' POL</span>' + (d.tx ? '<a class="when" target="_blank" rel="noopener" href="' + explorer + '/tx/' + d.tx + '">verify ↗</a>' : '<span class="when"></span>') + '</div>').join('')
|
$('mine').innerHTML = board.drips.length ? board.drips.map(d => '<div class="row"><span>' + esc(d.site) + '</span><span class="site">' + ({ paid: 'paid', sent: 'sending', due: 'paying next', queued: 'queued for the next pool', failed: 'held, being looked at' }[d.status] || d.status) + '</span><span class="pol">+' + d.pol + ' POL</span>' + (d.tx ? '<a class="when" target="_blank" rel="noopener" href="' + explorer + '/tx/' + d.tx + '">verify ↗</a>' : '<span class="when"></span>') + '</div>').join('')
|
||||||
: '<div class="row"><span class="site">Nothing yet. Your first find goes here.</span></div>';
|
: '<div class="row"><span class="site">Nothing yet. Your first find goes here.</span></div>';
|
||||||
@@ -169,7 +170,7 @@
|
|||||||
+ '<button type="button" data-x aria-label="Close" style="position:absolute;top:10px;right:12px;background:none;border:0;color:var(--muted);font-size:26px;line-height:1;cursor:pointer">×</button>'
|
+ '<button type="button" data-x aria-label="Close" style="position:absolute;top:10px;right:12px;background:none;border:0;color:var(--muted);font-size:26px;line-height:1;cursor:pointer">×</button>'
|
||||||
+ '<div style="font:700 12px var(--font);letter-spacing:.14em;text-transform:uppercase;color:var(--ok)">All ' + dl.done + ' missions done today</div>'
|
+ '<div style="font:700 12px var(--font);letter-spacing:.14em;text-transform:uppercase;color:var(--ok)">All ' + dl.done + ' missions done today</div>'
|
||||||
+ '<h2 id="phDoneH" style="margin:8px 0 10px;font:700 23px/1.25 var(--font)">Nice hunting. Keep earning on InstantAdPay.</h2>'
|
+ '<h2 id="phDoneH" style="margin:8px 0 10px;font:700 23px/1.25 var(--font)">Nice hunting. Keep earning on InstantAdPay.</h2>'
|
||||||
+ '<p style="margin:0 0 16px;color:var(--muted);line-height:1.55">New missions open at midnight Central. Until then, view ads on InstantAdPay to earn ad credits, then put them to work: run your own ad, or grab an ad package that pays your sponsor line on-chain.</p>'
|
+ '<p style="margin:0 0 16px;color:var(--muted);line-height:1.55">New missions open at midnight Central. Until then, head to InstantAdPay: <b>open an inbox ad and watch a video</b> to bank an extra hunt for Friday, and earn ad credits while you are there.</p>'
|
||||||
+ '<div style="display:flex;flex-wrap:wrap;gap:10px">'
|
+ '<div style="display:flex;flex-wrap:wrap;gap:10px">'
|
||||||
+ '<a class="btn" href="https://instantadpay.com/my#earn">Earn ad credits</a>'
|
+ '<a class="btn" href="https://instantadpay.com/my#earn">Earn ad credits</a>'
|
||||||
+ '<a class="btn ghost" href="https://instantadpay.com/my#buy">See ad packages</a></div></div>';
|
+ '<a class="btn ghost" href="https://instantadpay.com/my#buy">See ad packages</a></div></div>';
|
||||||
@@ -180,6 +181,27 @@
|
|||||||
document.body.appendChild(w);
|
document.body.appendChild(w);
|
||||||
try { w.querySelector('[data-x]').focus(); } catch (e) {}
|
try { w.querySelector('[data-x]').focus(); } catch (e) {}
|
||||||
}
|
}
|
||||||
|
// Friday Bonus Hunts (2026-09-26): banked on InstantAdPay Sat-Thu, used here on Friday.
|
||||||
|
function fridayCard(fb) {
|
||||||
|
const el = $('fbank'); if (!el) return;
|
||||||
|
if (!fb || !fb.available) { el.hidden = true; return; }
|
||||||
|
const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
||||||
|
const wd = d => WD[new Date(d + 'T12:00:00Z').getUTCDay()];
|
||||||
|
const chips = (fb.days || []).map(d => {
|
||||||
|
const c = d.banked ? 'var(--ok)' : d.day === fb.today ? 'var(--gold)' : 'var(--edge)';
|
||||||
|
return '<span style="display:inline-block;margin:0 6px 6px 0;padding:3px 10px;border-radius:999px;border:1px solid ' + c + ';font-size:13px">' + (d.banked ? '✓ ' : '') + wd(d.day) + '</span>';
|
||||||
|
}).join('');
|
||||||
|
const t = (fb.days || []).find(d => d.day === fb.today);
|
||||||
|
let line;
|
||||||
|
if (fb.isFriday) line = fb.bonus ? '<b>It is Friday: +' + fb.bonus + ' bonus hunt' + (fb.bonus === 1 ? '' : 's') + ' today</b> from the days you banked.' : 'It is Friday. Bank hunts Saturday through Thursday on InstantAdPay for next Friday.';
|
||||||
|
else if (t && t.banked) line = '✓ <b>Today is banked.</b> Come back tomorrow for another.';
|
||||||
|
else line = 'Bank today: on InstantAdPay, <b>watch one video</b>' + (t && !t.soloNeeded ? '' : ' and <b>open one inbox ad</b>') + '. <a href="https://instantadpay.com/my#earn">Go bank it</a>';
|
||||||
|
const capNote = fb.banked > fb.usable ? ' <span class="small" style="color:var(--muted)">(' + fb.usable + ' usable: one per open mission)</span>' : '';
|
||||||
|
el.innerHTML = '<div style="font:700 12px var(--font);letter-spacing:.12em;text-transform:uppercase;color:var(--pol-hi)">Friday Bonus Hunts</div>'
|
||||||
|
+ '<div style="margin:6px 0 8px;font-size:15px"><b>' + fb.banked + '</b> banked for Friday' + capNote + '</div>'
|
||||||
|
+ '<div>' + chips + '</div><div style="font-size:14px;color:var(--muted)">' + line + '</div>';
|
||||||
|
el.hidden = false;
|
||||||
|
}
|
||||||
let explorer = 'https://polygonscan.com';
|
let explorer = 'https://polygonscan.com';
|
||||||
async function load() { board = await api('/api/my/board'); render(); }
|
async function load() { board = await api('/api/my/board'); render(); }
|
||||||
async function start(id) {
|
async function start(id) {
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ const store = require('./lib/store');
|
|||||||
const sso = require('./lib/sso');
|
const sso = require('./lib/sso');
|
||||||
const missions = require('./lib/missions');
|
const missions = require('./lib/missions');
|
||||||
const rewards = require('./lib/rewards');
|
const rewards = require('./lib/rewards');
|
||||||
|
const fridaybank = require('./lib/fridaybank'); // Friday Bonus Hunts (2026-09-26)
|
||||||
|
const activeMissionCount = () => missions.list().filter(m => m.active && !m.paid).length;
|
||||||
|
const fbFor = me => fridaybank.forHunter(me, activeMissionCount(), rewards.settings().missionsPerDay || 3);
|
||||||
const social = require('./lib/social');
|
const social = require('./lib/social');
|
||||||
const badge = require('./lib/badge');
|
const badge = require('./lib/badge');
|
||||||
const referrals = require('./lib/referrals'); // pays a hunter for bringing someone who turns up and hunts
|
const referrals = require('./lib/referrals'); // pays a hunter for bringing someone who turns up and hunts
|
||||||
@@ -85,7 +88,7 @@ async function postBadge(p) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Marty's rule (2026-09-19): when the day's pool is spent, say so; claims reopen at midnight Central
|
// Marty's rule (2026-09-19): when the day's pool is spent, say so; claims reopen at midnight Central
|
||||||
const dailyMsg = d => 'That is your ' + ['', 'one', 'two', 'three', 'four', 'five'][d.limit] + ' for today. Fresh missions at midnight Central.';
|
const dailyMsg = d => 'That is your ' + (['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'][d.limit] || d.limit) + ' for today. Fresh missions at midnight Central.';
|
||||||
const SPENT_MSG = 'Today\u2019s POL pool is spent. No more claims today. Claims reopen at midnight Central.';
|
const SPENT_MSG = 'Today\u2019s POL pool is spent. No more claims today. Claims reopen at midnight Central.';
|
||||||
function refOf(req) { const m = /(?:^|;\s*)ph\.ref=([^;]+)/.exec(req.headers.cookie || ''); const r = m ? decodeURIComponent(m[1]) : ''; return /^[A-Za-z0-9_.-]{1,40}$/.test(r) ? r : null; }
|
function refOf(req) { const m = /(?:^|;\s*)ph\.ref=([^;]+)/.exec(req.headers.cookie || ''); const r = m ? decodeURIComponent(m[1]) : ''; return /^[A-Za-z0-9_.-]{1,40}$/.test(r) ? r : null; }
|
||||||
function explorer() { return Number(process.env.HUNT_CHAIN_ID) === 80002 ? 'https://amoy.polygonscan.com' : 'https://polygonscan.com'; }
|
function explorer() { return Number(process.env.HUNT_CHAIN_ID) === 80002 ? 'https://amoy.polygonscan.com' : 'https://polygonscan.com'; }
|
||||||
@@ -221,9 +224,10 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p.startsWith('/api/my/')) {
|
if (p.startsWith('/api/my/')) {
|
||||||
const me = sso.fromRequest(req); if (!me) return json(res, 401, { error: 'Open PolHunter from your InstantAdPay dashboard to sign in.' });
|
const me = sso.fromRequest(req); if (!me) return json(res, 401, { error: 'Open PolHunter from your InstantAdPay dashboard to sign in.' });
|
||||||
if (p === '/api/my/board') {
|
if (p === '/api/my/board') {
|
||||||
|
const fbank = await fbFor(me);
|
||||||
referrals.seen(me); // hunters already signed in never pass through /auth again, so keep the directory fresh here too
|
referrals.seen(me); // hunters already signed in never pass through /auth again, so keep the directory fresh here too
|
||||||
const done = rewards.doneToday(me.memberId, me.wallet); const wdone = done; // today's finds, by member id or wallet
|
const done = rewards.doneToday(me.memberId, me.wallet); const wdone = done; // today's finds, by member id or wallet
|
||||||
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet }, missions: missions.forMember(me.memberId).map(m => Object.assign(pubMission(m), { done: done.has(m.id) || wdone.has(m.id) })), drips: rewards.mine(me.memberId).slice(0, 20), faucet: { on: faucetOn }, pool: rewards.pool(), daily: rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet)),
|
return json(res, 200, { me: { memberId: me.memberId, username: me.username, wallet: me.wallet }, missions: missions.forMember(me.memberId).map(m => Object.assign(pubMission(m), { done: done.has(m.id) || wdone.has(m.id) })), drips: rewards.mine(me.memberId).slice(0, 20), faucet: { on: faucetOn }, pool: rewards.pool(), daily: rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fbank.bonus), fridayBank: fbank,
|
||||||
badges: social.badgesFor(me.memberId), badgeCards: (() => { const got = new Set(social.badgesFor(me.memberId).map(b => b.id)); const who = social.nameOf(me); return social.BADGES.map(b => ({ id: b.id, name: b.name, icon: b.icon, why: b.why, art: '/badges/badge-' + b.id + '.jpg', earned: got.has(b.id), page: got.has(b.id) ? SITE + '/b/' + who + '/' + b.id : null, image: got.has(b.id) ? SITE + '/badge-img/' + who + '/' + b.id + '.jpg' : null })); })(), rank: { week: social.rankOf(me.memberId, 'week'), month: social.rankOf(me.memberId, 'month'), all: social.rankOf(me.memberId, 'all') },
|
badges: social.badgesFor(me.memberId), badgeCards: (() => { const got = new Set(social.badgesFor(me.memberId).map(b => b.id)); const who = social.nameOf(me); return social.BADGES.map(b => ({ id: b.id, name: b.name, icon: b.icon, why: b.why, art: '/badges/badge-' + b.id + '.jpg', earned: got.has(b.id), page: got.has(b.id) ? SITE + '/b/' + who + '/' + b.id : null, image: got.has(b.id) ? SITE + '/badge-img/' + who + '/' + b.id + '.jpg' : null })); })(), rank: { week: social.rankOf(me.memberId, 'week'), month: social.rankOf(me.memberId, 'month'), all: social.rankOf(me.memberId, 'all') },
|
||||||
share: { link: social.shareLink(SITE, me), joinUrl: 'https://instantadpay.com/join/' + encodeURIComponent(String(me.username || me.memberId)) + '?from=polhunter' },
|
share: { link: social.shareLink(SITE, me), joinUrl: 'https://instantadpay.com/join/' + encodeURIComponent(String(me.username || me.memberId)) + '?from=polhunter' },
|
||||||
referral: referrals.state(me) });
|
referral: referrals.state(me) });
|
||||||
@@ -233,7 +237,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (!me.wallet) return json(res, 400, { error: 'Link a wallet on InstantAdPay first so the drip has somewhere to land, then open PolHunter again.' });
|
if (!me.wallet) return json(res, 400, { error: 'Link a wallet on InstantAdPay first so the drip has somewhere to land, then open PolHunter again.' });
|
||||||
if (rewards.completed(me.memberId, m.id, me.wallet)) return json(res, 400, { error: 'You already completed this one.' });
|
if (rewards.completed(me.memberId, m.id, me.wallet)) return json(res, 400, { error: 'You already completed this one.' });
|
||||||
{ const pool = rewards.pool(); if (pool.spent) return json(res, 400, { error: SPENT_MSG, spent: true, resetsAt: pool.resetsAt }); }
|
{ const pool = rewards.pool(); if (pool.spent) return json(res, 400, { error: SPENT_MSG, spent: true, resetsAt: pool.resetsAt }); }
|
||||||
{ const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet)); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
{ const fb = await fbFor(me); const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fb.bonus); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
||||||
if (limited('start:' + me.memberId, 20, 3600000)) return json(res, 429, { error: 'Easy. Twenty starts an hour is plenty.' });
|
if (limited('start:' + me.memberId, 20, 3600000)) return json(res, 429, { error: 'Easy. Twenty starts an hour is plenty.' });
|
||||||
const t = missions.issue(me.memberId, m.id);
|
const t = missions.issue(me.memberId, m.id);
|
||||||
// a mission URL may place the token itself with {token} (a Telegram Mini App takes it in
|
// a mission URL may place the token itself with {token} (a Telegram Mini App takes it in
|
||||||
@@ -249,7 +253,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const m = missions.get(c.rec.missionId); if (!m) return json(res, 404, { error: 'That mission is gone.' });
|
const m = missions.get(c.rec.missionId); if (!m) return json(res, 404, { error: 'That mission is gone.' });
|
||||||
if (rewards.completed(me.memberId, m.id, me.wallet)) return json(res, 400, { error: 'You already completed this one.' });
|
if (rewards.completed(me.memberId, m.id, me.wallet)) return json(res, 400, { error: 'You already completed this one.' });
|
||||||
{ const pool = rewards.pool(); if (pool.spent) return json(res, 400, { error: SPENT_MSG, spent: true, resetsAt: pool.resetsAt }); }
|
{ const pool = rewards.pool(); if (pool.spent) return json(res, 400, { error: SPENT_MSG, spent: true, resetsAt: pool.resetsAt }); }
|
||||||
{ const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet)); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
{ const fb = await fbFor(me); const d = rewards.daily(me.memberId, rewards.doneToday(me.memberId, me.wallet), fb.bonus); if (!d.left) return json(res, 400, { error: dailyMsg(d), dailyDone: true, resetsAt: rewards.pool().resetsAt }); }
|
||||||
const before = new Set(social.badgesFor(me.memberId).map(b => b.id));
|
const before = new Set(social.badgesFor(me.memberId).map(b => b.id));
|
||||||
const g = rewards.grant(me, m); if (g.error) return json(res, 400, g);
|
const g = rewards.grant(me, m); if (g.error) return json(res, 400, g);
|
||||||
// whoever brought this hunter gets paid for it: the bounty on their first find, a match while they are new
|
// whoever brought this hunter gets paid for it: the bounty on their first find, a match while they are new
|
||||||
|
|||||||
Reference in New Issue
Block a user