Make appeal ban endpoint use path param

This commit is contained in:
Regalijan 2023-10-30 12:16:59 -04:00
parent 91a2f2ea5c
commit aaf8c880d8
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -2,14 +2,15 @@ import { jsonError } from "../../../common.js";
export async function onRequestPost(context: RequestContext) {
const { current_user: currentUser } = context.data;
const targetId = context.params.id as string;
if (context.data.targetId.search(/^\d{16,19}$/) === -1)
if (targetId.search(/^\d{16,19}$/) === -1)
return jsonError("Invalid target id", 400);
await context.env.D1.prepare(
"INSERT INTO appeal_bans (created_at, created_by, user) VALUES (?, ?, ?);",
)
.bind(Date.now(), context.data.current_user.id, context.data.targetId)
.bind(Date.now(), context.data.current_user.id, targetId)
.run();
await fetch(context.env.APPEALS_WEBHOOK, {
@ -18,7 +19,7 @@ export async function onRequestPost(context: RequestContext) {
{
title: "User Blocked",
color: 3756250,
description: `User ${context.data.targetId} was blocked from the appeal form.`,
description: `User ${targetId} was blocked from the appeal form.`,
fields: [
{
name: "Moderator",