Greatly reduce repeated code
This commit is contained in:
@ -1,13 +1,10 @@
|
||||
import { jsonError } from "../../../common.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { current_user: currentUser } = context.data;
|
||||
|
||||
if (context.data.targetId.search(/^\d{16,19}$/) === -1)
|
||||
return new Response('{"error":"Invalid target id"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 400,
|
||||
});
|
||||
return jsonError("Invalid target id", 400);
|
||||
|
||||
await context.env.D1.prepare(
|
||||
"INSERT INTO appeal_bans (created_at, created_by, user) VALUES (?, ?, ?);",
|
||||
|
Reference in New Issue
Block a user