Backend: - Complete FastAPI backend with 42+ REST endpoints (auth, servers, config, players, bans, missions, mods, games, system) - Game adapter architecture with Arma 3 as first-class adapter - WebSocket real-time events for status, metrics, logs, players - Background thread system (process monitor, metrics, log tail, RCon poller) - Fernet encryption for sensitive config fields at rest - JWT auth with admin/viewer roles, bcrypt password hashing - SQLite with WAL mode, parameterized queries, migration system - APScheduler cleanup jobs for logs, metrics, events Frontend: - Server Detail page with 7 tabs (overview, config, players, bans, missions, mods, logs) - Settings page with password change and admin user management - Create Server wizard (4-step; known bug: silent validation failure) - New hooks: useServerDetail, useAuth, useGames - New components: ServerHeader, ConfigEditor, PlayerTable, BanTable, MissionList, ModList, LogViewer, PasswordChange, UserManager - WebSocket onEvent callback for real-time log accumulation - 120 unit tests passing (Vitest + React Testing Library) Docs: - Added .gitignore, CLAUDE.md, README.md - Updated FRONTEND.md, ARCHITECTURE.md with current implementation state - Added .env.example for backend configuration Known issues: - Create Server form: "Next" buttons don't validate before advancing, causing silent submit failure when fields are invalid - Config sub-tabs need UX redesign for non-technical users
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
import json
|
|
from datetime import datetime, timezone
|
|
from core.dal.base_repository import BaseRepository
|
|
|
|
|
|
class BanRepository(BaseRepository):
|
|
|
|
def get_all(self, server_id: int, active_only: bool = True) -> list[dict]:
|
|
if active_only:
|
|
return self._fetchall(
|
|
"SELECT * FROM bans WHERE server_id = :sid AND is_active = 1 ORDER BY banned_at DESC",
|
|
{"sid": server_id},
|
|
)
|
|
return self._fetchall(
|
|
"SELECT * FROM bans WHERE server_id = :sid ORDER BY banned_at DESC",
|
|
{"sid": server_id},
|
|
)
|
|
|
|
def create(
|
|
self,
|
|
server_id: int,
|
|
guid: str | None,
|
|
name: str | None,
|
|
reason: str | None,
|
|
banned_by: str,
|
|
expires_at: str | None = None,
|
|
game_data: dict | None = None,
|
|
) -> int:
|
|
return self._lastrowid(
|
|
"""
|
|
INSERT INTO bans (server_id, guid, name, reason, banned_by, expires_at, game_data)
|
|
VALUES (:sid, :guid, :name, :reason, :by, :exp, :gd)
|
|
""",
|
|
{
|
|
"sid": server_id,
|
|
"guid": guid,
|
|
"name": name,
|
|
"reason": reason,
|
|
"by": banned_by,
|
|
"exp": expires_at,
|
|
"gd": json.dumps(game_data or {}),
|
|
},
|
|
)
|
|
|
|
def deactivate(self, ban_id: int) -> None:
|
|
self._execute(
|
|
"UPDATE bans SET is_active = 0 WHERE id = :id",
|
|
{"id": ban_id},
|
|
)
|
|
|
|
def get_by_id(self, ban_id: int) -> dict | None:
|
|
return self._fetchone("SELECT * FROM bans WHERE id = :id", {"id": ban_id}) |