feat: establish NekoNest Cloud control and relay
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { getCloudViewer } from "@/app/cloud-auth";
|
||||
import { resolveFeedback } from "@/db/repository";
|
||||
import { apiError, readJsonMutation } from "../../respond";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const viewer = await getCloudViewer();
|
||||
if (!viewer) {
|
||||
return Response.json(
|
||||
{ error: "authentication_required", message: "请先登录" },
|
||||
{ status: 401 },
|
||||
);
|
||||
}
|
||||
if (!viewer.isAdmin) {
|
||||
return Response.json(
|
||||
{ error: "forbidden", message: "没有公测后台权限" },
|
||||
{ status: 403 },
|
||||
);
|
||||
}
|
||||
const payload = await readJsonMutation<{
|
||||
feedbackId?: string;
|
||||
response?: string;
|
||||
reason?: string;
|
||||
idempotencyKey?: string;
|
||||
}>(request);
|
||||
const feedback = await resolveFeedback({
|
||||
feedbackId: payload.feedbackId ?? "",
|
||||
actorId: viewer.userId,
|
||||
response: payload.response ?? "",
|
||||
reason: payload.reason ?? "",
|
||||
idempotencyKey: payload.idempotencyKey ?? "",
|
||||
});
|
||||
return Response.json({ feedback });
|
||||
} catch (error) {
|
||||
return apiError(error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user