Commit Graph

41 Commits

Author SHA1 Message Date
hobokenchicken 2d897e45ed feat: dynamic pricing by disk space + episode count, total requests stat, disk bar graph 2026-04-23 12:36:50 -04:00
hobokenchicken 515dba07ac fix: explicitly encode overseer search query 2026-04-23 12:12:52 -04:00
hobokenchicken 3dcece5c67 feat: ko-fi integration for credit purchases 2026-04-23 11:59:05 -04:00
hobokenchicken 4a68cc85f3 fix: tautulli backfill use individual sessions, client-side date filter, actual watch time 2026-04-23 11:42:01 -04:00
hobokenchicken 3b9d709589 fix: use duration field, guard null started/stopped, cap 10h 2026-04-23 11:24:26 -04:00
hobokenchicken 29f3201fc5 fix: tautulli get_history use after=unix_ts not start_date 2026-04-23 11:08:08 -04:00
hobokenchicken 137bf19a02 fix: manual bigint casting in admin analytics 2026-04-23 10:55:31 -04:00
hobokenchicken 46984adda4 feat: manual backfill for admin 2026-04-23 10:36:34 -04:00
hobokenchicken ddeacb2543 fix: add requests to admin analytics 2026-04-23 10:21:58 -04:00
hobokenchicken 9be0b46e2f fix: global bigint serialization 2026-04-23 10:17:46 -04:00
hobokenchicken bf57169014 fix: sync pending requests from overseer 2026-04-23 09:14:44 -04:00
hobokenchicken fb32a66996 fix: log overseer webhook payload 2026-04-22 14:35:30 -04:00
hobokenchicken 5a8eb90c38 fix: overseer status coercion 2026-04-22 14:11:02 -04:00
hobokenchicken a5dd85f5c1 fix: normalize overseer webhook statuses 2026-04-22 14:10:03 -04:00
hobokenchicken f0b3338f08 fix: live update request status 2026-04-22 13:53:37 -04:00
hobokenchicken f944b1f9b4 chore: final solana purge 2026-04-22 13:37:22 -04:00
hobokenchicken 4bfcbb6b7e chore: remove solana wallet stack 2026-04-22 13:32:14 -04:00
hobokenchicken 8ec91acc25 refactor: db-only credits and admin controls
Remove blockchain dependence from credit flow:
- watch credits now DB-only
- webhook earnings now DB-only
- wallet balance now DB-only
- admin bonus/adjustment routes operate on DB totals

Add admin adjustment API for account control.
Keep Solana service file unused for now; safe to delete later.
2026-04-22 13:05:48 -04:00
hobokenchicken 86a8c7d89a feat(economy): tighten credit earning + deduct on request
Credit economy changes:
- creditsPerMinute: 10 -> 2 (45min episode = 90 COOP vs 450)
- movieRequestCost: 100 -> 500 (~5.5 episodes per movie)
- tvRequestCost: 200 -> 1000 (~11 episodes per season)
- tvPerSeasonCost: 50 -> 250

Race condition fix:
- Credits now deducted immediately at request time
- No more multiple requests before approval
- On DECLINED: automatic refund with ADJUSTMENT transaction
- On APPROVED: no extra deduction (already paid)

Updated schema defaults and all code fallbacks.
2026-04-21 15:50:18 -04:00
hobokenchicken fee4d8ce1b fix(balance): use database credits instead of on-chain balance
Balance checks were reading on-chain Solana token balance (0
during db-only mode). Now wallet and overseer routes return
user.totalEarned - user.totalSpent as the usable credit balance.
This makes credits spendable even when devnet faucet is dry.

- /wallet returns dbBalance, with onChainBalance as extra info
- /overseer/balance returns dbBalance for request eligibility
- /overseer/request checks dbBalance before approving spend
- /wallet/admin returns dbBalance
2026-04-21 15:37:06 -04:00
hobokenchicken 5dbee115ad chore(solana): silence devnet airdrop retry spam
Catch and swallow airdrop errors quietly. Logs were flooded with
429 retry messages. Now fails fast and lets DB-only credits take
over when devnet faucet is dry.
2026-04-21 15:31:19 -04:00
hobokenchicken 31d89f049b fix(solana): graceful fallback to DB-only credits when blockchain unavailable
Devnet airdrop faucet rate-limited. mintTokens() now returns a
db-only signature instead of failing when Solana is unreachable,
unfunded, or mint creation fails. This lets watch events and
backfill still credit users in the database. Blockchain minting
will resume automatically once SOL is available.
2026-04-21 15:25:21 -04:00
hobokenchicken 871c01c79e fix(solana): airdrop SOL to mint authority before creating mint
Mint authority had zero SOL balance on devnet, causing
'Attempt to debit an account but found no record of a prior
credit' error. Now getTokenMint() checks balance, airdrops 2 SOL
if needed, then creates the SPL token mint. Also added caching
so mint is only created once.
2026-04-21 15:18:45 -04:00
hobokenchicken 9b5d477852 fix(solana): auto-create token mint on devnet if not configured
getTokenMint() was a stub returning null. Now checks SOLANA_MINT_ADDRESS
env var first, then auto-creates a new SPL token mint on devnet using
the existing mint authority keypair. This enables actual token minting
for backfill and live watch events.
2026-04-21 15:13:56 -04:00
hobokenchicken c38117fbe7 fix(backfill): map Plex username to Tautulli user ID before fetching history
Tautulli get_history requires internal user_id, not Plex ID.
Now queries get_users first, matches by username/email/friendly_name,
then uses matched user's ID for history fetch.
2026-04-21 15:00:28 -04:00
hobokenchicken 946b81384c fix(crypto): SHA-256 hash ENCRYPTION_KEY for AES-256-GCM
ENCRYPTION_KEY was 64 hex chars = 64 bytes. AES-256 needs exactly
32 bytes. Now hashing with SHA-256 to derive proper 32-byte key
regardless of input length. Fixed in auth.ts backfill encrypt
and wallet.ts encrypt/decrypt.
2026-04-21 14:53:55 -04:00
hobokenchicken 338e2a1fc1 feat(auth): backfill 30 days watch history on signup
New users automatically get credited for their last 30 days of
Plex watch history via Tautulli. Creates wallet if needed,
fetches history, calculates credits with same rules as live
webhooks, mints tokens, and creates watchEvent + transaction
records. Only runs on first-time signup.
2026-04-21 14:40:36 -04:00
hobokenchicken 2215eb900b fix(backend): session dedupe + mint authority JSON array parsing
1. Auth callback now deletes old sessions before creating new one,
   and adds Date.now() nonce to JWT to prevent unique constraint
   violations on duplicate login attempts.

2. Solana mint authority now accepts both JSON array and base58
   formats for SOLANA_MINT_AUTHORITY_KEYPAIR env var.
2026-04-21 14:26:21 -04:00
hobokenchicken f191ad4e4c fix(auth): coerce Plex ID to string for Prisma
Plex API returns user.id as integer but Prisma schema expects
String for plexId. Wrapped with String() to fix login 500.
2026-04-21 13:53:32 -04:00
hobokenchicken 5751e08eb1 fix(auth): use Plex PIN flow instead of OAuth2 code exchange
Plex auth uses PIN-based flow, not standard OAuth2 authorization_code.

- backend/auth: POST /api/v2/pins to create PIN, GET /api/v2/pins/{id} to get authToken
- frontend/login: store pinId in sessionStorage before redirect
- frontend/callback: send pinId to backend instead of query code
- backend/index: fix dotenv path resolution for tsx (__dirname returns '.')
2026-04-21 09:27:00 -04:00
Your Name 7e68f57d69 Fix: support coop FQDN for dashboard access 2026-04-18 02:10:06 +00:00
Your Name 425fb007f3 Fix: Update CORS and network config for dev IP access 2026-04-18 01:45:27 +00:00
Your Name 4d6e36ec24 Fix: Improve Plex OAuth flow and initialization 2026-04-18 01:32:13 +00:00
Your Name 61bbca2e5d Refactor: Improve error handling in authentication flow 2026-04-17 19:55:35 +00:00
hobokenchicken 2388873e7a fix: Docker build and runtime fixes
- Fix duplicate 'signature' variable in webhooks.ts
- Add Prisma binary target for Alpine Linux
- Fix tsconfig path alias (@/* -> ./src/*)
- Add missing next-themes dependency
- Add build args for NEXT_PUBLIC_* env vars
- Fix SSR issues with zustand and providers
- Add providers-wrapper with dynamic ssr:false import
- Add SSL certs and public dir for nginx
- Update Dockerfiles for proper Prisma engine handling
2026-04-15 14:16:27 -04:00
hobokenchicken a1572d327f fix: relax tsconfig and add @types/bs58 for build
- Set strict: false and disable strict type checking options
- Add @types/bs58 dev dependency
- Fixes TypeScript compilation errors in Docker build
2026-04-14 15:58:08 -04:00
hobokenchicken 895e74c657 fix: add @unique to Transaction.requestId for one-to-one relation
Prisma requires unique fields on the defining side of one-to-one relations.
Fixes P1012 validation error during prisma generate.
2026-04-14 15:55:04 -04:00
hobokenchicken d2e20ad82a fix: docker build - use root context for monorepo workspaces
- Change build context from ./frontend|backend to root (.)
- Update Dockerfiles to copy from correct paths
- Use npm install instead of npm ci (workspaces share root lockfile)
- Remove obsolete version attribute from docker-compose.yml

Fixes npm ci errors when package-lock.json is at workspace root.
2026-04-14 15:45:27 -04:00
hobokenchicken 2e8260bc8c security: upgrade dependencies to fix critical and high vulnerabilities
- next: 14.2.15 → 15.2.5 (fixes critical DoS, SSRF, cache poisoning)
- react/react-dom: 18.2.0 → 19.1.0
- @solana/spl-token: 0.3.9 → 0.4.14 (bigint-buffer overflow fix)
- vitest: 1.1.0 → 3.0.0 (esbuild dev server exposure fix)
- mocha: 9.0.3 → 11.7.5 (serialize-javascript RCE fix)
- @solana/wallet-adapter-*: latest versions
- Add npm overrides for elliptic, lodash, esbuild, nanoid

Vulnerabilities: 44 (1 critical) → 23 (3 high, 20 low)

Refs: npm audit fixes for GHSA-7m27-7ghc-44w9, GHSA-3gc7-fjrx-p6mg
2026-04-14 14:15:48 -04:00
hobokenchicken 2e41156046 chore: add .env.example template files
Add environment variable templates for:
- Root .env.example (all services)
- backend/.env.example (API configuration)
- frontend/.env.local.example (client config)

Copy to .env and fill in your secrets before running.
2026-04-14 11:14:37 -04:00
hobokenchicken e8d9b1fd42 feat: add CoopCredits Solana media rewards ecosystem
Add complete  token system with Plex/Tautulli/Overseer integration:
- Anchor program for SPL token mint/burn/transfer
- Express backend with OAuth, webhooks, Solana integration
- Next.js frontend with dashboard, admin panel, wallet management
- Docker deployment for 172.20.1.0/24 infrastructure
- Production configs with SSL, Nginx, health monitoring

Tautulli webhooks auto-mint  on watch events.
Overseer integration burns  for content requests.
2026-04-14 11:09:50 -04:00