Files
ECS-FullStack/checklist.md
2025-10-10 18:51:23 -04:00

185 lines
16 KiB
Markdown

# Project Checklist (tidy & current)
Below are implemented features - [x] Front - [x] Live updates between bot and frontend using SSE events for real-time log synchronization (admin logs update immediately when moderation actions occur)nd UI for admin logs configuration in Server Settings
- [x] Database schema for storing moderation action logs
- [x] Require reason field (minimum 3 words) for all moderation commands
- [x] Admin Logs UI: added logs display section showing recent moderation actions with detailsd pending items, grouped by area.
## Backend
- [x] Express API: OAuth, server settings, channel/role endpoints, leave
- [x] Invite endpoints (GET/POST/DELETE) and invite-token issuance
- [x] Per-command toggles persistence and management
- [x] Config endpoints for welcome/leave and autorole
- [x] Admin Logs API endpoints: GET/POST for admin logs configuration, GET for retrieving moderation action logs
- [x] Frontend Moderation API: POST endpoint for direct ban/kick/timeout actions from web interface
- [x] Server Members API: GET endpoint for fetching server members for moderation user selection
- [x] SSE events: added botStatusUpdate events for real-time bot join/leave notifications
## Frontend
- [x] Login, Dashboard, Server Settings pages
- Login redirects to Dashboard after OAuth and user/guilds are persisted in localStorage
- Dashboard is protected: user must be logged in to view (redirects to login otherwise)
- [x] MUI components, responsive layout, mobile fixes
- [x] Theme switching (persist local) and user settings UI with adjusted light theme background
- [x] Invite UI: create form, list, copy, delete with confirmation
- [x] Commands UI (per-command toggles)
- [x] Admin commands (kick/ban/timeout) removed from regular commands list, only shown in Admin Commands section
- [x] Live Notifications UI (per-server toggle & config)
- Channel selection, watched-user list, live status with Watch Live button
- Real-time updates: adding/removing users via frontend or bot commands publishes SSE `twitchUsersUpdate` and pushes settings to bot
- Bot commands (`/add-twitchuser`, `/remove-twitchuser`) refresh local cache immediately after backend success
- Message mode: toggle between Default and Custom; Apply sends `message`/`customMessage` (default fallback if empty); no longer dual free-form fields
- Collapsible accordion interface: separate Twitch and Kick tabs (Kick tab disabled)
- [x] Admin Commands UI: dedicated section for moderation commands with toggle controls
- [x] Moderation Commands (`/kick`, `/ban`, `/timeout`) displayed with permission requirements and toggle switches
- [x] Admin Logs Configuration UI: channel selection and per-command enable/disable toggles
- [x] Frontend Moderation Actions: direct ban/kick/timeout functionality from web interface with user autocomplete dropdown
- [x] User permission validation and reason requirements (minimum 3 words)
- [x] Integration with backend moderation API and admin logging system
- [x] Admin Logs channel selection: shows all server text channels (not just channels where bot has permission) and updates immediately when changed
- [x] Admin logs properly save moderator usernames for both bot slash commands and frontend moderation actions, and persist across page refreshes
## Discord Bot
- [x] discord.js integration (events and commands)
- [x] Slash commands: `/create-invite`, `/list-invites`, `/manage-commands`, `/help`
- [x] Bot used by backend to fetch live guild data and manage invites
- [x] Bot reads/writes per-guild command toggles via backend/Postgres
- [x] Backend immediately notifies bot of toggle changes (pushes updated settings to bot cache) so frontend toggles take effect instantly
- [x] New slash command: `/setup-live` to enable/disable Twitch live notifications for the server (preserves other settings)
- [x] Frontend: Confirm dialog and working Delete action for Twitch watched users in Live Notifications
- [x] Live Notifications: bot posts message to configured channel with stream title and link when a watched Twitch user goes live
- [x] Live Notifications: bot posts rich embed to channel when a watched Twitch user goes live (thumbnail, clickable title, bio/description, category/game, viewers, footer with "ehchadservices" and start datetime)
- [x] Live Notifications polling frequency set to 5 seconds (configurable via `TWITCH_POLL_INTERVAL_MS`)
- [x] On bot restart, sends messages for currently live watched users; then sends for new streams once per session
- [x] Twitch Watcher Debug Logging: comprehensive debug mode added (enable with `TWITCH_WATCHER_DEBUG=true`) to track guild checks, settings retrieval, stream fetching, channel permissions, and message sending for troubleshooting live notification issues
- [x] Twitch API Functions Export Fix: added missing `tryFetchTwitchStreams` and `_rawGetTwitchStreams` to api.js module exports to resolve "is not a function" errors
- [x] Twitch Streams Array Safety: added `Array.isArray()` checks in twitch-watcher.js to prevent "filter is not a function" errors when API returns unexpected data types
- [x] Twitch Commands Postgres Integration: updated all Discord bot Twitch commands (`/add-twitchuser`, `/remove-twitchuser`) to use api.js functions for consistent Postgres backend communication
- [x] Twitch Message Template Variables: added support for `{user}`, `{title}`, `{category}`, and `{viewers}` template variables in custom live notification messages for dynamic content insertion
- [x] Frontend JSX Syntax Fix: fixed React Fragment wrapping for admin logs map to resolve build compilation errors
- [x] Frontend: show "Watch Live" button next to watched user when they are live (links to Twitch)
- [x] Bi-directional sync: backend POST/DELETE for twitch-users now also pushes new settings to bot process (when `BOT_PUSH_URL` configured)
- [x] Bot adds/removes users via backend endpoints ensuring single source of truth (Postgres)
- [x] Live notifications toggle on site enables/disables watching and publishes SSE for real-time updates
- [x] /manage-commands command has enable/disable buttons that sync with frontend via backend API and SSE for live updating
- [x] All Twitch-related commands (add, remove, list) and frontend actions communicate with backend and Postgres database
- [x] Welcome/Leave messages: bot sends configured messages to channels when users join/leave
- [x] Welcome messages with {user} and {server} placeholders
- [x] Leave messages with {user} placeholder
- [x] Autorole assignment on member join
- [x] All settings managed through Server Settings UI
- [x] Event handlers properly integrated with API settings
- [x] Kick live notifications bot integration (temporarily disabled)
- [x] New slash commands: `/add-kickuser`, `/remove-kickuser`, `/list-kickusers` (commands exist but watcher disabled)
- [x] Kick API polling and notification posting (watcher removed, API endpoints remain)
- [x] Per-server Kick user management via backend API (endpoints functional)
- [x] Frontend tabs: separate Twitch and Kick tabs in Live Notifications accordion (Kick tab disabled)
- [x] Bot watcher temporarily disabled in index.js startup
- [x] Dev command filtering: commands marked with `dev: true` are hidden from UI, help, and Discord registration
- [x] Admin Moderation Commands: `/kick`, `/ban`, `/timeout` with proper permission checks and role hierarchy validation
- [x] Commands accept user mentions or user IDs as input to allow targeting any user (not limited by Discord's user selection filtering)
- [x] Frontend integration: web interface moderation actions with permission validation
- [x] Moderation actions are logged to postgres database with reasons and automatically posted to configured admin logs channel
- [x] Admin logs properly capture and display the moderator who performed the action (both from bot slash commands and frontend)
- [x] Admin Logs System: event logging for moderation actions
- [x] New slash command: `/setup-adminlogs` to configure logging channel and per-command enable/disable
- [x] Bot posts detailed moderation logs to configured channel showing: command used, target user, moderator, date/time, reason (required min 3 words), duration, end date
- [x] Backend API endpoints for admin logs configuration and retrieval
- [x] Frontend UI for admin logs configuration in Server Settings
- [x] Database schema for storing moderation action logs
- [x] Require reason field (minimum 3 words) for all moderation commands
- [x] Admin logs are unique to each guild and stored in postgres database
- [x] Frontend delete buttons for individual logs and delete all logs with confirm dialogs
- [x] Live updates between bot and frontend using SSE events for real-time log synchronization
- [x] Admin logs properly display the username who called the command and the user they called it on for both bot slash commands and frontend moderation actions
- [x] Bot command username logging fixed: uses correct Discord user properties (username/global_name instead of deprecated tag)
- [x] Bot event handlers: added guildCreate and guildDelete events to publish SSE notifications for live dashboard updates
- [x] Invite synchronization: real-time sync between Discord server events and frontend
- [x] Discord event handlers for inviteCreate and inviteDelete events
- [x] Only bot-created invites are tracked and synchronized
- [x] Frontend SSE event listeners for inviteCreated and inviteDeleted events
- [x] Backend API updated to store existing invites from Discord events
- [x] Invite deletions from Discord server are immediately reflected in frontend
- [x] Offline reconciliation: bot detects and removes invites deleted while offline on startup
- [x] Automatic cleanup of stale invites from database and frontend when bot comes back online
- [x] Reaction Roles: configurable reaction-role messages with buttons
- [x] Backend table `reaction_roles` and CRUD endpoints
- [x] Frontend accordion UI to create/edit/delete reaction role configurations (channel, named buttons, role picker, embed)
- [x] Live SSE updates when reaction roles are created/updated/deleted
- [x] Bot posts embedded message with buttons and toggles roles on button press
- [x] Replacement of confirm() with app `ConfirmDialog` and role picker dropdown in UI
- [x] Initial and periodic reconciliation: bot removes DB entries when the message or channel is missing
- [x] Backend: tolerate JSON string payloads for `embed` and `buttons` when creating/updating reaction roles (auto-parse before inserting JSONB)
- [x] Slash command `/post-reaction-role <id>` for admins to post a reaction role message from Discord
- [x] Frontend edit functionality for existing reaction roles
- [x] Button ID stability: customId uses roleId instead of array index for robustness
## Database
- [x] Postgres support via `DATABASE_URL` (backend auto-creates `servers`, `invites`, `users`)
- [x] Legacy encrypted `backend/db.json` retained (migration planned)
- [x] Kick.com live notifications: backend API, frontend UI, bot integration
- Database schema: kickUsers table with userId, username, guildId
- API endpoints: GET/POST/DELETE /api/servers/:guildId/kick-users
- Bot commands: /add-kickuser, /remove-kickuser, /list-kickusers
- Frontend tabs: separate Twitch and Kick tabs in Live Notifications accordion
- Kick API integration: polling for live status, stream metadata, web scraping fallback for 403 errors
- Per-server configuration: all settings scoped by guildId
- [x] Schema: live notification settings stored in server settings (via `liveNotifications` JSON)
- Fields: `enabled`, `channelId`, `users[]`, `kickUsers[]`, `message`, `customMessage` (custom overrides default if non-empty)
- Users list preserved when updating other live notification settings (fixed: kickUsers now also preserved)
- [x] Admin Logs Database Schema: new table for storing moderation action logs
- Fields: id, guildId, action (kick/ban/timeout), targetUserId, targetUsername, moderatorUserId, moderatorUsername, reason, duration, endDate, timestamp
## Security & Behavior
- [x] Invite DELETE requires short-lived HMAC token (`x-invite-token`)
- [x] Frontend confirmation dialog for invite deletion
- [ ] Harden invite-token issuance (require OAuth + admin check)
- [ ] Template variables for messages (planned): support `{user}`, `{title}`, `{category}`, `{viewers}` replacement in `message` / `customMessage`
- [x] Moderation Command Requirements: require reason field (minimum 3 words) for all moderation commands (`/kick`, `/ban`, `/timeout`)
- [x] ServerSettings back button: fixed to navigate to dashboard instead of browser history to prevent accidental accordion opening
## Docs & Deployment
- [x] README and CHANGELOG updated with setup steps and Postgres guidance
- Core env vars: `DATABASE_URL`, `DISCORD_CLIENT_ID`, `DISCORD_CLIENT_SECRET`, `DISCORD_BOT_TOKEN`, `INVITE_TOKEN_SECRET`, `ENCRYPTION_KEY`, `HOST`, `PORT`, `CORS_ORIGIN`
- Frontend: set `REACT_APP_API_BASE` to backend URL before build
- Tailscale: bind backend to your tailnet IP (100.x.y.z) and set `DATABASE_URL` to a Postgres reachable over the tailnet
Notes:
- `backend/.env.example` and `frontend/.env.example` are templates — copy to `.env` and fill values.
- Postgres / pgAdmin: create DB & user, set `DATABASE_URL`; backend auto-creates tables on startup.
UI tweaks applied:
- Server cards: uniform sizes, image cropping, name clamping
- Mobile spacing and typography adjustments
- Dashboard action buttons repositioned (Invite/Leave under title)
- Live Notifications: collapsible accordion with tabbed interface for Twitch and Kick tabs (Kick tab disabled)
- [x] All accordions in ServerSettings: consistently grayed out (opacity 0.5) when bot is not in server
- [x] Footer component: added global footer showing "© ehchadservices.com 2025" on all pages
- [x] Dashboard live reloading: real-time updates when bot joins/leaves servers via SSE events
- [x] Responsive design: mobile-friendly layout with adaptive padding, typography, and component sizing
- [x] Ultra-wide screen support: max-width constraints and overflow prevention
- [x] Sticky footer: footer positioned at bottom of viewport regardless of content height
- [x] Navbar branding: title shows "ECS" on mobile, "EhChadServices" on desktop
- [x] Dashboard welcome text: updated to "Welcome back, {username}" with even larger typography (h3/h2 variants) and increased spacing; title also enlarged (h4/h3) for better proportion and explicit margin-bottom for clear line separation
- [x] Browser tab now shows `ECS - <Page Name>` (e.g., 'ECS - Dashboard')
- [x] Dashboard duplicate title fixed; user settings (avatar/themes) restored via NavBar
- [x] Maintenance page
- Frontend displays a maintenance page with a loading indicator when the backend is offline; it polls the backend and reloads UI immediately when the backend is available.
- [x] Global backend health & SSE
- [x] Added `BackendContext` to centralize health polling and a single shared EventSource
- [x] Pages (including `ServerSettings`) use the shared event bus for live updates so the whole site receives changes in real-time
- [ ] Frontend file re-organization
- [ ] Verify guild-scoped SSE payloads include guildId and frontend filters events by guild (in-progress)
- [ ] Add debug SSE publish endpoint to help validate real-time flows (done, guarded by DEBUG_SSE)
- [x] Created `frontend/src/lib/api.js` and refactored some modules to use it
- [x] Created `frontend/src/components/common` and `frontend/src/components/server`
- [x] Moved `ConfirmDialog` and `MaintenancePage` to `components/common`
- [x] Moved `ServerSettings` and `HelpPage` to `components/server`
- [x] Fixed ESLint warnings: removed unused imports and handlers, added proper dependency management
- [x] Fixed compilation errors: added missing MUI imports and Snackbar component
- [x] Navbar visibility: enhanced with solid background and stronger border for better visibility across all themes