Repository navigation
feat: credit codes (Premium days), invite bonus and affiliate links (0.6.0) - #301
Merged
Merged
Conversation
- @profullstack/redeem-credits 0.2.0: a code grants unit premium_days. Redeeming writes user_subscriptions through grant_premium_days(), the row a paid Premium plan already lives on, idempotent per (user, source); days go on the end of a running plan or trial, Family stays Family. - Invites stay the existing system (5 a month, required to sign up). New: once an invited member confirms their email, both people get 7 Premium days at sign-in (grant_invite_bonus(), inviter capped at 5 a month, invites accepted from 2026-10-26). - @profullstack/affiliates 0.2.0: a stable ?ref= link per member on /invites, first touch recorded at sign-up from the existing referral_code cookie (no second cookie; codes from @profullstack/stack/referrals come back external and are left to it). - Pages: "Have a code?" on /account (Subscription) and /settings, /invites, /i/<code> short invite links (now what invite links use). API: POST /api/account/redeem, /api/admin/credit-codes (mint/list/revoke). CLI: pnpm credits mint|list|revoke. - Migrations 20261026130000/130100/130200 (applied on dev2 before merge). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
ThreatCrush Security Scan97 finding(s) HIGH/CRITICAL: 11 | MEDIUM: 30 | LOW: 56
…and 47 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Credit code redemptions and invite/affiliate links for bittorrented.com (fleet rollout batch 1). Anthony 2026-10-26: "mint him a token i can give him to redeem credits ... add credit code redemptions and invite codes/(affiliate) to all properties".
What a code grants:
@profullstack/redeem-credits0.2.0, unitpremium_days, codes look likeBT-XXXX-XXXX-XXXX-XXXX. A redeemed code goes throughgrant_premium_days(), which writesuser_subscriptions. That is the same row a paid Premium plan already uses (activate_subscription), so every existing Premium check sees it and there is no new flag. Days are added after the end of a running plan or trial, and Family stays Family. It is idempotent per (user, source), so a retried hook never adds days twice.Invites: bittorrented already has scarce invites: 5 a month, required to sign up, enforced by the
a_consume_invite_on_signuptrigger. They stay the invite system. A secondINV-code would not satisfy the signup trigger, and 3 more invites per account would double the supply. What is new:grant_invite_bonus()). The inviter can collect this at most 5 times a month. Only invites accepted from 2026-10-26 count, so nothing is paid out retroactively. Admin-seeded invites have no inviter. Banned or unconfirmed accounts get nothing. The bonus is paid on/api/auth/login, and on/api/auth/mefor magic-link and nixamp sign-ins (once per process per member).:a short invite link that redirects to/signup?invite=<code>. The code travels in the URL, not a cookie. Invite links now use it, and old/signup?invite=links still work. It is in all three open lists (site-offline, proxy PUBLIC_PATHS, legal-mode)./invite-only), now with the bonus line and the member's referral link.Affiliate links:
@profullstack/affiliates0.2.0. Each member has one stable?ref=code. First touch is recorded at sign-up throughrefFromRequest(), which reads the existingreferral_codecookie that the proxy'strackReferralCodealready sets, so there is no second cookie. Codes from the older@profullstack/stack/referralstable come backexternaland are left to that system, so nothing is double counted.Surfaces:
POST /api/account/redeemGET/POST/DELETE /api/admin/credit-codes(admins only, 404 otherwise)pnpm credits mint --days N [--max N] [--label T] [--expires DATE] | list | revoke <id>The repo has no MCP server.
Migrations:
20261026130000_redeem_credits.sqland20261026130100_affiliates.sqlare copied verbatim from the packages.20261026130200_premium_day_grants.sqladds the table, the two functions (service_role only) and a pgrst reload. All three were applied by hand on dev2 before merge (backup~/backups/bittorrented/credits-invites.bak-001.sqlplusschema-public.bak-001.sql). They were first dry-run in a rolled-back transaction with a functional test: unconfirmed → refused, confirmed → both +7, repeat →already_granted, code grant idempotent,authenticated→ permission denied.Tests: new
src/lib/rewards.test.ts, plus route tests for redeem, admin credit codes and/i/<code>. The legal-mode and site-offline lists, invites API and invite link tests are updated. Full suite: 3134 pass.tscis clean andnext buildis OK.Not done: there is no affiliate commission payout. bittorrented has no payout ledger, so
aff.commission()is not wired into the CoinPay webhook yet.🤖 Generated with Claude Code