Skip to content

feat(reports,puzzles): implement player reporting and puzzle bulk import tool (#466, #467) - #498

Merged
Mkalbani merged 1 commit into
MindFlowInteractive:mainfrom
Alhaandr:feature/issue-466-467-player-reporting-puzzle-import
Nov 20, 2026
Merged

Mkalbani merged 1 commit into
MindFlowInteractive:mainfrom
Alhaandr:feature/issue-466-467-player-reporting-puzzle-import

Conversation

@Alhaandr

Copy link
Copy Markdown
Contributor

Summary

This pull request implements two backend features:

  1. In-Game Player Reporting (In-Game Player Reporting #467): Enables players to report other players for cheating, abusive names, or abusive chat with supporting evidence, with duplicate prevention, spam rate limiting, priority-based routing to the moderation queue, and automated resolution outcome notifications for reporters.
  2. Puzzle Bulk Import Tool (Puzzle Bulk Import Tool #466): Enables content administrators to bulk import puzzles from structured files (JSON, CSV, YAML), including per-record validation with exact row number reporting, a non-destructive dry-run simulation mode, transactional database commits, and persistent import history tracking.

What changed

In-Game Player Reporting (#467)

  • Schema & Reasons:
    • Added ReportReason enum (cheating, abusive_name, abusive_chat, other).
    • Added evidence text column to ContentReport entity.
    • Added CreatePlayerReportDto and extended CreateReportDto to support optional evidence and reasons.
  • Submission Endpoints:
    • Implemented dedicated POST /reports/player endpoint for submitting player reports.
    • Retained and updated POST /reports for general content/player reporting with evidence.
  • Duplicate Prevention & Abuse Throttling:
    • Re-enforced duplicate detection blocking open reports from the same reporter on the same target.
    • Added NestJS @Throttle({ default: { limit: 5, ttl: 60000 } }) decorators on submission endpoints.
    • Added service-level sliding window rate-limiting (checkRateLimit) preventing spam reporting beyond configured thresholds.
  • Moderation Queue:
    • Exposed GET /reports/queue in ReportsController and getModerationQueue in ReportsService returning reports ordered by priority and recency.
    • Emitted report.queued event upon report creation.
  • Reporter Outcome Notification:
    • Extended report.resolved payload and ReportEventsListener to deliver notifications to reporters containing resolution outcome details.
  • Unit Tests:
    • Added tests in reports.service.spec.ts, reports.controller.spec.ts, and report-events.listener.spec.ts covering player report creation, duplicate prevention, rate limiting, moderation queue retrieval, and notifications.

Puzzle Bulk Import Tool (#466)

  • Schema & Entities:
    • Created PuzzleImportHistory entity (puzzle_import_history table) tracking import batches, admin ID, filename, format, record counts, dry-run flag, and detailed JSON execution report.
    • Created BulkImportPuzzlesDto and PuzzleImportFormat enum (json, csv, yaml).
  • File Upload & Parsing:
    • Added POST /admin/puzzles/import and POST /admin/puzzles/bulk-import supporting multipart/form-data file uploads via FileInterceptor and JSON payloads.
    • Multi-format parser for JSON arrays, { puzzles: [...] }, CSV files with quoted values and nested JSON strings/arrays, and YAML.
  • Per-Record Validation & Error Reporting:
    • Validates title, description, category, difficulty enum, content (question & correctAnswer), basePoints, timeLimit, and hint limits.
    • Tracks and reports errors with exact 1-based row numbers (row, title, errors).
  • Dry-Run Mode:
    • dryRun: true mode validates all records, generates a full report (validCount, invalidCount, row errors), logs dry-run history, and makes zero modifications to the puzzles table.
  • Transactional Commit:
    • Uses TypeORM DataSource.transaction to ensure valid puzzle records are committed atomically.
  • Import History:
    • Added GET /admin/puzzles/import/history and GET /admin/puzzles/import/history/:id to retrieve past import logs.
    • Integrated with AdminAuditLogService for audit trail tracking.
  • Unit Tests:
    • Added unit test suite puzzle-bulk-import.service.spec.ts covering multi-format imports, dry-run isolation, transaction atomicity, row-number error tracking, and history retrieval.
    • Updated admin-puzzles.controller.spec.ts to test import and history endpoints.

Why

  • In-Game Player Reporting #467: Protects the game community from cheating, offensive usernames, and toxic chat by providing a secure, rate-limited reporting pathway that funnels actionable reports into the moderation queue and keeps reporters informed.
  • Puzzle Bulk Import Tool #466: Streamlines puzzle content operations, allowing content admins to safely preview and bulk-upload puzzle catalogs with instant validation feedback without manual entry errors.

Testing performed

  • Unit Tests:
    • npm test -- src/reports src/puzzles/services/puzzle-bulk-import.service.spec.ts src/admin/controllers/__tests__/admin-puzzles.controller.spec.ts
    • 5 test suites passed, 44 tests passed (0 failures).
  • TypeScript Type Verification:
    • Verified compilation via npx tsc --project tsconfig.build.json --noEmit across all modified and newly created files.

Risks considered

  • Spam & False Reporting: Addressed via rate limiting (5 requests/min per IP/user and 10 reports/hour service-level cap) and duplicate open report checks.
  • Database Corruption on Large Imports: Addressed via dry-run simulation mode and atomic database transactions (DataSource.transaction), rolling back completely if a fatal database error occurs.
  • Breaking API Changes: All existing endpoints (POST /reports, GET /reports, AdminPuzzlesController routes) remain fully backwards-compatible.

Edge cases handled

  • Quoted CSV fields containing commas and serialized JSON content.
  • CSV row numbers accurately accounted for header row offset (starting at row 2).
  • Zero records or empty files reject early with descriptive BadRequestException.
  • Duplicate active reports on the same target return BadRequestException.
  • Reports auto-escalate to CRITICAL when 5+ reports are submitted within 24 hours.

Closes #466
Closes #467

…ort tool (MindFlowInteractive#466, MindFlowInteractive#467)

- MindFlowInteractive#467 In-Game Player Reporting:
  - Add ReportReason enum and evidence field
  - Implement player report submission endpoint POST /reports/player and extend POST /reports
  - Prevent duplicate reports from same reporter on same active target
  - Route reports to moderation queue with priority scoring, auto-escalation, and GET /reports/queue
  - Add request throttling and service-level rate limiting to deter spam abuse
  - Notify reporter with resolution outcome via ReportEventsListener
  - Add comprehensive unit tests

- MindFlowInteractive#466 Puzzle Bulk Import Tool:
  - Add PuzzleImportHistory entity and BulkImportPuzzlesDto for structured file imports (JSON, CSV, YAML)
  - Implement file upload and parsing with multi-format support
  - Validate each record with exact row numbers for any malformed fields
  - Add dry-run mode returning validation report without committing database changes
  - Commit valid records atomically in a transaction via DataSource.transaction
  - Record import history log in database and AdminAuditLog
  - Add import endpoints to AdminPuzzlesController and comprehensive unit tests

Closes MindFlowInteractive#466
Closes MindFlowInteractive#467
@drips-wave

drips-wave Bot commented Nov 20, 2026

Copy link
Copy Markdown

@Alhaandr Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Mkalbani
Mkalbani merged commit eb07ade into MindFlowInteractive:main Nov 20, 2026
@grantfox-oss grantfox-oss Bot mentioned this pull request Nov 20, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In-Game Player Reporting Puzzle Bulk Import Tool

2 participants