Make appeal ban endpoint use path param
This commit is contained in:
parent
91a2f2ea5c
commit
aaf8c880d8
@ -2,14 +2,15 @@ import { jsonError } from "../../../common.js";
|
|||||||
|
|
||||||
export async function onRequestPost(context: RequestContext) {
|
export async function onRequestPost(context: RequestContext) {
|
||||||
const { current_user: currentUser } = context.data;
|
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);
|
return jsonError("Invalid target id", 400);
|
||||||
|
|
||||||
await context.env.D1.prepare(
|
await context.env.D1.prepare(
|
||||||
"INSERT INTO appeal_bans (created_at, created_by, user) VALUES (?, ?, ?);",
|
"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();
|
.run();
|
||||||
|
|
||||||
await fetch(context.env.APPEALS_WEBHOOK, {
|
await fetch(context.env.APPEALS_WEBHOOK, {
|
||||||
@ -18,7 +19,7 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
{
|
{
|
||||||
title: "User Blocked",
|
title: "User Blocked",
|
||||||
color: 3756250,
|
color: 3756250,
|
||||||
description: `User ${context.data.targetId} was blocked from the appeal form.`,
|
description: `User ${targetId} was blocked from the appeal form.`,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "Moderator",
|
name: "Moderator",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user