+++ title = "quotesdb/api: reports table and POST /api/quotes/:id/report endpoint" priority = 5 status = "done" ticket_type = "feature" dependencies = [] +++ ## Summary Create a reports table and a public endpoint for reporting quotes for moderation review. ## Schema ```sql CREATE TABLE reports ( id TEXT PRIMARY KEY, -- NanoID quote_id TEXT NOT NULL REFERENCES quotes(id) ON DELETE CASCADE, reason TEXT, -- optional, max 256 chars created_at DATETIME DEFAULT CURRENT_TIMESTAMP ); ``` ## API Endpoint POST /api/quotes/:id/report - Body: { reason?: string } — reason is optional, max 256 chars - Validates reason length (400 if > 256 chars) - Creates a report record - Returns 201 on success - Returns 404 if quote not found ## Rate Limiting Note Rate limiting will be handled separately at the Cloudflare layer (see infra ticket 06d304). No application-level rate limiting needed here. ## Acceptance Criteria - [ ] reports table created in migration - [ ] POST /api/quotes/:id/report works - [ ] reason is optional and validated (max 256 chars) - [ ] 404 on unknown quote_id - [ ] Unit tests cover success, missing quote, reason too long ## Validation ```sh cargo fmt && cargo check && cargo clippy && cargo test ```