You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/quotesdb/.beans/quotesdb-i37j--quotesdbapi-...

46 lines
1.3 KiB
Markdown

---
# quotesdb-i37j
title: 'quotesdb/api: reports table and POST /api/quotes/:id/report endpoint'
status: completed
type: feature
priority: normal
created_at: 2026-03-10T23:32:08Z
updated_at: 2026-03-10T23:32:08Z
---
## 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
```