mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-06-29 04:35:40 +08:00
- New BugReport MongoDB model (comment, contact, userId, screenshot, pmState, status) - POST /api/bug-reports — authenticated submit; emails emanuel@faktorxmensch.com on receipt - GET/PATCH /api/admin/bug-reports + /[id] — admin list, detail with screenshot, status toggle - /pm: "Bug" button in HUD captures viewport screenshot (html2canvas), shows annotation canvas where testers can draw arrows; submits comment + contact + state snapshot - /admin: new "Bug Reports" tab with open-count badge, screenshot expand, "Erledigt" toggle, and "In /pm öffnen" link that restores captured engine state via ?restoreBugReport=<id> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
808 B
TypeScript
28 lines
808 B
TypeScript
import { defineEventHandler, getRouterParam, readBody, createError } from 'h3'
|
|
import { requireAdmin } from '../../../utils/auth'
|
|
import { BugReport } from '../../../models/BugReport'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
await requireAdmin(event)
|
|
|
|
const id = getRouterParam(event, 'id')
|
|
const body = await readBody(event)
|
|
|
|
const status = body?.status
|
|
if (status !== 'open' && status !== 'resolved') {
|
|
throw createError({ statusCode: 400, statusMessage: 'status must be "open" or "resolved"' })
|
|
}
|
|
|
|
const doc = await BugReport.findByIdAndUpdate(
|
|
id,
|
|
{ $set: { status } },
|
|
{ new: true },
|
|
).lean() as any
|
|
|
|
if (!doc) {
|
|
throw createError({ statusCode: 404, statusMessage: 'Bug report not found' })
|
|
}
|
|
|
|
return { id: String(doc._id), status: doc.status }
|
|
})
|