Drip Runner referrals: /join/<ref>?from=driprunner returns newcomers to the game once they have a username, first-touch source driprunner.saasy.top, hand-off carries sponsorRef/joinedRef

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-30 17:14:05 -05:00
parent f1b37e0c4a
commit 2b2e131c3e
3 changed files with 8 additions and 4 deletions
+5 -3
View File
@@ -1317,6 +1317,7 @@ const server = http.createServer(async (req, res) => {
const set = [];
set.push('iap.sponsor=' + tok + cookieTail); // last touch wins
if (u.searchParams.get('from') === 'polhunter') set.push('iap.return=polhunter' + cookieTail); // came through a PolHunter share link: send them back after the wallet step
if (u.searchParams.get('from') === 'driprunner') set.push('iap.return=driprunner; Path=/; SameSite=Lax; Max-Age=7200' + (IS_PROD ? '; Secure' : '')); // a Drip Runner share link: back into the game once they have a username
const promo = promos.norm(u.searchParams.get('promo')); if (promo) set.push('iap.promo=' + promo + cookieTail); // partner code, redeemed at signup
if (promo) { const pref = String(req.headers.referer || '').replace(/^https?:\/\//, '').split('/')[0].toLowerCase().slice(0, 80); if (pref) set.push('iap.promoref=' + encodeURIComponent(pref) + cookieTail); } // which partner page it came from
if (ang) set.push('iap.angle=' + angle + cookieTail);
@@ -1326,7 +1327,7 @@ const server = http.createServer(async (req, res) => {
// rather than dependent on a header (Marty, 2026-09-24: "not just members that come on board
// IAP and work their way over to POL Hunter").
if (!cookies['iap.ref']) {
const host = u.searchParams.get('from') === 'polhunter' ? 'polhunter.com' : coach.refHost(req.headers.referer);
const host = u.searchParams.get('from') === 'polhunter' ? 'polhunter.com' : u.searchParams.get('from') === 'driprunner' ? 'driprunner.saasy.top' : coach.refHost(req.headers.referer);
set.push('iap.ref=' + encodeURIComponent(host) + cookieTail);
}
return serveJoinPage(res, tok, ang ? angle : '', ang, set);
@@ -1696,7 +1697,7 @@ const server = http.createServer(async (req, res) => {
const _defSpon = Number(siteConfig().defaultSponsorId) || 1;
if (!sponsorId && memberId !== _defSpon) sponsorId = _defSpon; // orphan fallback → #1 (never self-sponsor)
if (memberId && acct && acct.memberId !== memberId) accounts.setMemberId(acct.email, memberId).catch(() => {});
const out = { signedIn: true, returnTo: parseCookies(req)['iap.return'] === 'polhunter' ? 'polhunter' : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
const out = { signedIn: true, returnTo: ['polhunter', 'driprunner'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
address: s.address || (acct && acct.address) || null, memberId,
username: (acct && acct.username) || null,
refCode: (acct && acct.code) || null, sponsorId,
@@ -2432,7 +2433,8 @@ const server = http.createServer(async (req, res) => {
if (DR_SECRET().length < 32) return json(res, 503, { error: 'Drip Runner is not connected yet.' });
const acct = await accounts.byEmail(s.email);
const memberId = (acct && acct.memberId) || s.memberId || 0;
const tok = drMint({ memberId: Number(memberId), email: s.email, wallet: (acct && acct.address) || s.address || null, username: (acct && acct.username) || null });
const tok = drMint({ memberId: Number(memberId), email: s.email, wallet: (acct && acct.address) || s.address || null, username: (acct && acct.username) || null,
sponsorRef: (acct && acct.sponsorRef) || null, joinedRef: (acct && acct.joinedRef) || null, joinedAt: (acct && acct.created) || null }); // the game credits referrals to the IAP sponsor
res.writeHead(302, { Location: DR_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': 'iap.return=; Path=/; SameSite=Lax; Max-Age=0' + (IS_PROD ? '; Secure' : '') }); return res.end();
}
// -- Drip Runner refuel: a real verified visit (advertiser charged as usual); the player gets fuel, not credits