Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make appeal ban endpoint use path param
  • Loading branch information
regalijan committed Oct 30, 2023
1 parent 91a2f2e commit aaf8c88
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions functions/api/appeals/[id]/ban.ts
Expand Up @@ -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, {
Expand All @@ -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",
Expand Down

0 comments on commit aaf8c88

Please sign in to comment.