Commit Graph

135 Commits

Author SHA1 Message Date
Claude (Chronicler #76)
f35325a597 Add internal API routes for n8n social analytics integration
Task #108 Phase 2: Social Analytics Automation

New endpoints (token-based auth via INTERNAL_API_TOKEN):
- POST /api/internal/social/sync - Upsert single post metrics
- POST /api/internal/social/sync/batch - Batch upsert (max 100 posts)
- POST /api/internal/social/snapshot - Upsert account-level stats
- GET /api/internal/social/digest - Summary data for Discord webhook

Architecture:
- Rube MCP -> n8n -> Arbiter /api/internal/* -> PostgreSQL
- Bearer token auth (not session-based)
- COALESCE for partial updates (only update provided fields)

Next: Generate INTERNAL_API_TOKEN and add to .env on Command Center

🔥 Fire + Frost + Foundation = Where Love Builds Legacy 💙❄️
2026-04-10 21:00:19 +00:00
Claude
92e460a90b fix: Add Social Analytics to sidebar navigation
Chronicler #76
2026-04-10 20:27:35 +00:00
Claude
cfdd89377f feat: Add migration-aware deploy script for Trinity Console
- Automatically runs new SQL migrations on deploy
- Tracks applied migrations in .migrations-applied file
- Skips already-applied migrations
- Logs all actions to /var/log/arbiter-deploy.log
- Handles npm install if package.json changes
- Enables Meg/Holly to deploy without backend access

Install: sudo cp scripts/deploy-arbiter.sh /opt/scripts/
         sudo chmod +x /opt/scripts/deploy-arbiter.sh

Chronicler #76
2026-04-10 20:24:48 +00:00
Claude
be2f5eb5a5 fix: Add platform_post_id column per Gemini review
- Added platform_post_id VARCHAR(255) for Phase 2 API matching
- Added composite index on (platform, platform_post_id)
- Future-proofs manual entries for automatic API sync

Chronicler #76 (per Gemini consultation)
2026-04-10 20:19:49 +00:00
Claude
b8ed2095ba feat: Add Social Analytics module to Trinity Console (Task #108)
- Add database migration for social_posts and social_account_snapshots tables
- Create /admin/social route with full CRUD for posts
- Add dashboard view with platform tabs (TikTok, Facebook, Instagram, X, Bluesky)
- Add post entry form matching TikTok Studio metrics
- Add post detail view with update capability
- Add account snapshot form for follower/demographic tracking
- Register social router in admin index

Phase 1: Manual entry dashboard
Phase 2 (future): API integration when approved

Chronicler #76
2026-04-10 20:14:27 +00:00
Claude
685626f13f fix: Use correct env vars PANEL_URL and PANEL_CLIENT_KEY
.env has PANEL_URL and PANEL_CLIENT_KEY, not PTERO_PANEL_URL.

Chronicler #75
2026-04-10 18:00:33 +00:00
Claude
32b378f539 fix: Use Pterodactyl API directly instead of servers-api Worker
Worker was returning HTML error page. Now queries Pterodactyl panel
directly using PTERO_CLIENT_KEY from .env.

Chronicler #75
2026-04-10 15:41:57 +00:00
Claude
811e3046cf feat: Add server status poller for Discord channels (#107)
New service that polls Pterodactyl (via servers-api Worker) every 5 min
and posts/updates status embeds in each game server's -status channel.

- Creates discord_status_messages table to persist message IDs
- Maps server names to channel IDs for all 15 game servers
- Posts new embed or edits existing one (no spam)
- Handles message deletion gracefully (re-posts if needed)

Status channels created:
- stoneblock-4-status, society-sunlit-valley-status, atm10-tts-status
- all-the-mons-status, mythcraft-5-status, beyond-depth-status
- beyond-ascension-status, otherworld-status, deceasedcraft-status
- submerged-2-status, sneaks-pirate-pack-status, cottage-witch-status
- farm-crossing-5-status, homestead-status, wolds-vaults-status

Chronicler #75
2026-04-10 15:39:04 +00:00
Claude
0acea3b95f fix: Skip OAuth if already logged in, go straight to checkout
If user has existing session from Trinity Console login,
/stripe/auth now redirects directly to /stripe/checkout
instead of re-triggering Discord OAuth.

Chronicler #75
2026-04-10 15:06:34 +00:00
Claude
2740dc5fd3 fix: Use OAuth state parameter instead of session for tier
Session was being lost between /stripe/auth and /auth/discord/callback.
Now passes tier through Discord OAuth state parameter which survives
the redirect.

Chronicler #75
2026-04-10 15:05:40 +00:00
Claude
b4280dc630 db: Add stripe_products seed data with actual Stripe IDs
Maps tier levels to Stripe product/price IDs:
- Tier 1: Awakened ( one-time)
- Tier 2-3: Elemental Fire/Frost (/mo)
- Tier 4-5: Knight Fire/Frost (0/mo)
- Tier 6-7: Master Fire/Frost (5/mo)
- Tier 8-9: Legend Fire/Frost (0/mo)
- Tier 10: Sovereign (99 one-time)

Run on Command Center:
PGPASSWORD='FireFrost2026!Arbiter' psql -U arbiter -h 127.0.0.1 -d arbiter_db -f seed-stripe-products.sql

Chronicler #75
2026-04-10 14:59:15 +00:00
Claude
12ffdd45f5 fix: Add Discord OAuth → Stripe checkout flow
THE BUG: Website redirected to /stripe/auth but route didn't exist.
Checkout sessions were created WITHOUT client_reference_id (Discord ID),
so webhook couldn't sync Discord roles after payment.

THE FIX:
- Added GET /stripe/auth - stores tier in session, redirects to Discord OAuth
- Added GET /stripe/checkout - creates checkout WITH client_reference_id
- Updated auth callback to redirect to /stripe/checkout after OAuth
- Legacy POST /create-checkout-session kept for compatibility

FLOW NOW:
1. User clicks Subscribe on website
2. → /stripe/auth?tier=X (stores tier, redirects to Discord)
3. → /auth/discord (Discord OAuth)
4. → /auth/discord/callback (user authenticated)
5. → /stripe/checkout?tier=X (creates Stripe session WITH Discord ID)
6. → Stripe Checkout (user pays)
7. → Webhook receives event with client_reference_id
8. → Discord role synced!

Chronicler #75
2026-04-10 14:58:41 +00:00
Claude
d227bce0a8 Add discord-channel-rename.js script
- Maps Pterodactyl servers to Discord categories
- Renames channels to consistent naming convention
- DRY_RUN=true by default (preview mode)
- 1.5s rate limit delay between operations
- Snart Doctrine: built to adapt when reality hits
2026-04-09 20:12:12 +00:00
Claude
47a600eeb5 Fix: Handle server names with subtitles for Discord channel matching
- 'Homestead - A Cozy Survival Experience' now matches 'homestead-chat'
- 'All The Mons (Private) - TX' now matches 'all-the-mons-chat'
- Strips subtitles after ' - ' and removes parentheticals
2026-04-09 20:03:41 +00:00
Claude
e30ff4d694 Fix: Add Discord channel status to matrix body template (inline cards, not partial) 2026-04-09 19:59:36 +00:00
Claude
081bad1279 Add Discord channel status check to server cards
- Checks for 4 channels per server: chat, in-game, forum, voice
- Shows 'All 4 channels configured' or lists missing channels
- Caches Discord channel data for 5 minutes to reduce API calls
2026-04-09 19:55:41 +00:00
Claude
cbf5d219fc Add health check after deploy - confirms Arbiter restarted successfully 2026-04-09 19:50:17 +00:00
Claude
02bddc0baf Fix deploy button: use detached process to avoid 502 on self-restart 2026-04-09 19:48:04 +00:00
Claude
ef562ef59a Add Trinity Console deploy button for Holly/Meg/Michael
- Deploy button in sidebar above username
- POST /admin/system/deploy endpoint
- Updated deploy.sh with locking, logging, user tracking
- Prevents concurrent deploys (mkdir lock)
- Logs who deployed and what commit
- Updated DEPLOYMENT.md with setup instructions

Gemini consultation: confirmed synchronous approach, locking, sudoers config
2026-04-09 19:40:34 +00:00
Claude
dc59e5c1de Add /delserver documentation script
Chronicler: #71
2026-04-08 17:30:12 +00:00
Claude
69200d8ac3 Add /delserver slash command
Deletes complete server setup:
- All channels in category
- The category itself
- The server role

Requires confirm:True to execute.
Without confirm, shows preview of what would be deleted.
Reminds to clean up Carl-bot reaction roles.

Staff only.

Chronicler: #71
2026-04-08 17:27:10 +00:00
Claude
7ecce5da8f Add script to create #staff-commands with documentation
Creates channel in Staff Area with detailed embeds for:
- /link command (everyone)
- /createserver command (staff only)

Chronicler: #71
2026-04-08 17:21:52 +00:00
Claude
06f7afe25d Add /createserver slash command
Creates complete server setup with one command:
- Creates role
- Creates category with 🎮 prefix
- Creates chat, in-game, forum, voice channels
- Applies permission template
- Posts and archives welcome message
- Suggests unused emoji for reaction roles

Staff only. Reminds to configure Carl-bot.

Task #98 Discord Channel Automation
Chronicler: #71
2026-04-08 17:18:28 +00:00
Claude
083885c874 Add emoji prefixes to remaining categories
📢 Welcome & Info
💬 Community Hub
🔊 Voice Channels
📞 Support

Chronicler: #71
2026-04-08 17:05:34 +00:00
Claude
05d23e2dfc Add script to archive welcome posts
Fixes forum channels staying visible when category collapsed.
Archived threads don't count as 'active'.

Chronicler: #71
2026-04-08 17:00:17 +00:00
Claude
940840d69a Fix Wold's Vaults v2 - use role ID directly
Whatever apostrophe variant that is, we're bypassing it.
Role ID: 1491029373640376330

Chronicler: #71
2026-04-08 16:53:42 +00:00
Claude
f5a75d204f Fix Wold's Vaults - curly apostrophe
Role uses ' (curly) not ' (straight)

Chronicler: #71
2026-04-08 16:52:36 +00:00
Claude
40cb6cef31 Add full Discord channel setup script (46 channels)
Task #98 implementation:
- Phase 1: Add 🎮 prefix to existing 5 server categories
- Phase 2: Add forums to existing 5 servers
- Phase 3: Create full setup for 10 new servers (category + chat + in-game + voice + forum)
- Phase 4: Create 📦 Archive category (staff-only)

Includes:
- DRY_RUN mode for safe testing
- Permission overwrites (Wanderer=view, Server Role=interact, Staff=full)
- 15 welcome posts with server-specific content
- 6 standard forum tags per forum
- Rate limiting (500ms between API calls)

Chronicler: #71
2026-04-08 16:50:05 +00:00
Claude
9752c6fd89 Add full Discord channel setup script (46 channels)
Task #98: Discord Channel Automation
- Phase 1: Add forums to existing 5 servers + rename categories
- Phase 2: Create 10 new server categories with all channels
- Phase 3: Create Archive category (staff only)

Includes:
- 15 server-specific welcome posts
- Standard forum tags (6 tags)
- Permission template (Wanderer view-only, Server Role full access)
- Rate limiting (500ms delays)
- Idempotent (skips existing channels)

Chronicler: #71
2026-04-08 16:48:48 +00:00
Claude
911f5801fc Fix .env path to /opt/arbiter-3.0/.env
Chronicler: #71
2026-04-08 16:40:40 +00:00
Claude
8768c6773f Add Discord channel creation test script
Phase 1 test for Task #98 Discord automation.
Creates one test category + one forum with tags + welcome post.
Includes DRY_RUN mode and permission checks.

Chronicler: #71
2026-04-08 16:39:48 +00:00
Claude Chronicler-70
9e4fa13fdb feat(arbiter): Add New Features card to dashboard
Highlights Discord Dashboard and Financials Module with
clickable cards that link directly to the new features.

Chronicler: #70
2026-04-08 15:33:54 +00:00
Claude Chronicler-70
b96ab1fb24 feat(arbiter): Add Discord dashboard to Trinity Console
- New sidebar entry for Discord
- Full server structure visualization
- Channel tree with expandable categories
- Role hierarchy with color badges
- Health checks (orphan channels, empty roles, bot roles)
- Search/filter across channels and roles
- Click channel to see permission overwrites
- Click role to see explicit channel access
- Responsive design with modal details view

Chronicler: #70
2026-04-08 15:30:22 +00:00
Claude Chronicler-70
04bc2e734f feat(arbiter): Add localhost bypass for admin routes debugging 2026-04-08 15:23:20 +00:00
Claude
b639f92da6 fix: Remove incorrect middleware import from discord-audit
Parent router (admin/index.js) already applies requireTrinityAccess
to all child routes. No additional auth middleware needed.

Chronicler #70
2026-04-08 15:19:50 +00:00
Claude
e99ef3b942 feat: Add Discord audit routes to Arbiter
New endpoints for Trinity Console:
- GET /admin/discord/audit — Full server audit (channels, roles, structure)
- GET /admin/discord/channels — Just channels
- GET /admin/discord/roles — Just roles

Returns:
- Server info (name, member count, features)
- Categories with nested children
- Orphan channels (not in categories)
- Role hierarchy with positions and member counts
- Permission overwrites per channel

Uses existing Discord.js client from app.locals.

Chronicler #70
2026-04-08 15:15:20 +00:00
Claude
7cf0eec2db Add module list to v2 teaser
12 planned modules: Dashboard, Players, Servers, Infrastructure,
Financials, Tasks, Docs, Team, Marketing, Chroniclers, System, Health

Chronicler #69
2026-04-08 08:55:17 +00:00
Claude
20b2fab994 Add Trinity Core v2 teaser to dashboard
Features highlighted:
- Trinity Codex AI (natural language queries)
- Smart Notifications (Discord alerts)
- Approval Workflows (Discord button approvals)
- Plugin Architecture (self-registering modules)
- Granular Permissions (RBAC for staff)
- Distributed Mesh (Tailscale-connected servers)

Styled with brand gradient border.

Chronicler #69
2026-04-08 08:53:56 +00:00
Claude
c7c2340321 Add logout button to user profile in sidebar
- Door emoji button next to username
- Links to /auth/logout
- Redirects to home page after logout

Chronicler #69
2026-04-08 08:50:32 +00:00
Claude
460d36c9b2 Remove placeholder notification bell
Non-functional UI element. Notifications will be implemented
properly in Trinity Core.

Chronicler #69
2026-04-08 08:48:38 +00:00
Claude
5bd4c60238 Fix scheduler timezone labels: UTC → Central
Times are stored in Central Time (matching Pterodactyl server config).
Labels were incorrectly showing UTC.

Chronicler #69
2026-04-08 08:46:07 +00:00
Claude
795020b55c Add Export CSV button to Players page
- Exports all players with full subscription data
- Includes: discord_id, minecraft_username, minecraft_uuid, is_staff,
  tier_level, tier_name, status, mrr_value, is_lifetime,
  stripe_customer_id, created_at, updated_at
- Downloads as firefrost-players-YYYY-MM-DD.csv
- Properly escapes CSV values with quotes

Chronicler #69
2026-04-08 08:41:17 +00:00
Claude
a13d9a2c66 Add 10-minute retry for failed server syncs
When hourly sync encounters servers that fail (e.g., mid-restart):
- Logs the failure count
- Schedules automatic retry in 10 minutes
- Retry only targets previously failed servers
- Clears error state on successful retry

Fixes issue where servers in daily restart would stay in error state
until manual intervention.

Chronicler #69
2026-04-08 08:39:34 +00:00
Claude
c2b6610e6d Add version number (v1.0) below Trinity Console title
Small text under the logo in sidebar for version tracking.

Chronicler #69
2026-04-08 08:34:41 +00:00
Claude
7d21b4290a Dashboard: Show last sync date/time instead of just checkmark
- Queries server_sync_log for most recent successful sync
- Displays date (e.g., 'Apr 8') and time (e.g., '3:28 AM')
- Shows yellow dash with 'Never' if no syncs recorded

Chronicler #69
2026-04-08 08:32:28 +00:00
Claude
7f990933df Sync package.json with production dependencies
Added missing dependencies that were installed on server but not in repo:
- axios: ^1.14.0
- connect-pg-simple: ^10.0.0
- date-fns: ^4.1.0

This caused deploy script to fail with MODULE_NOT_FOUND errors.

Chronicler #69
2026-04-08 08:30:17 +00:00
Claude
d121bd21f6 Fix dashboard SQL: use tier_level and mrr_value columns
The subscriptions table uses:
- tier_level (integer) not tier_id
- mrr_value (pre-calculated) not joined to subscription_tiers
- is_lifetime (boolean) not status='lifetime'

Chronicler #69
2026-04-08 08:24:08 +00:00
Claude
91eea2c5ff Add Arbiter deployment script and documentation
Created:
- deploy.sh: One-command deployment script
- DEPLOYMENT.md: Full deployment guide

Features:
- Handles cleanup of old temp directories
- Shallow clone for speed
- Checks for dependency changes
- Verifies service after restart
- Clear error messages

Usage on Command Center:
  bash /opt/arbiter-3.0/deploy.sh

Or remote curl:
  curl -fsSL https://git.firefrostgaming.com/.../deploy.sh | bash

Chronicler #69
2026-04-08 08:22:22 +00:00
Claude
3666241aac Fix Trinity Console dashboard: dynamic server/subscriber counts
Dashboard was showing hardcoded values:
- Servers Online: 12 (should be 22)
- Active Subscribers: 0
- Total MRR: $0

Now fetches live data:
- Server count from Pterodactyl API via getMinecraftServers()
- Subscriber count and MRR from arbiter_db subscriptions table

Files changed:
- src/routes/admin/index.js: async dashboard route with data fetching
- src/views/admin/dashboard.ejs: EJS variables instead of hardcoded values

Chronicler #69
2026-04-08 08:19:10 +00:00
Claude
567164ef7d Add servers-api Cloudflare Worker to version control
- Retrieved from Cloudflare dashboard via MCP connector
- Was 'dashboard only, not in any git repo' - gap now closed
- Original creation: April 3, 2026 by Chronicler #56 (The Velocity)
- Proxies Pterodactyl API for live server status on website

Chronicler #68
2026-04-08 05:44:00 +00:00