Don't rely on metadata for appeals
This commit is contained in:
parent
3d5b830827
commit
8d7e9bd93d
@ -1,7 +1,7 @@
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { permissions } = context.data.current_user;
|
||||
|
||||
if (!(permissions & (1 << 0)) || !(permissions & (1 << 11)))
|
||||
if (!(permissions & (1 << 0)) && !(permissions & (1 << 11)))
|
||||
return new Response('{"error":"Forbidden"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
@ -15,9 +15,9 @@ export async function onRequestPost(context: RequestContext) {
|
||||
context.data.targetId = id;
|
||||
|
||||
if (!new URL(context.request.url).pathname.endsWith("/ban")) {
|
||||
const keyWithMeta = await context.env.DATA.getWithMetadata(`appeal_${id}`);
|
||||
const key = await context.env.DATA.get(`appeal_${id}`);
|
||||
|
||||
if (!keyWithMeta.value)
|
||||
if (!key)
|
||||
return new Response('{"error":"No appeal with that ID exists"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
@ -25,7 +25,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
status: 404,
|
||||
});
|
||||
|
||||
context.data.appeal = keyWithMeta;
|
||||
context.data.appeal = key;
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -1,8 +1,8 @@
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { metadata, value } = context.data.appeal;
|
||||
const { appeal } = context.data;
|
||||
const body = new FormData();
|
||||
body.append("from", "noreply@mail.carcrushers.cc");
|
||||
body.append("to", value.email);
|
||||
body.append("to", appeal.email);
|
||||
body.append("subject", "Appeal Accepted");
|
||||
body.append("template", "appeal_accepted");
|
||||
body.append("v:note", context.data.body.feedback || "No note provided.");
|
||||
@ -31,7 +31,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
const { current_user: currentUser } = context.data;
|
||||
|
||||
await fetch(
|
||||
`https://discord.com/api/v10/guilds/242263977986359297/bans/${metadata.id}`,
|
||||
`https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.id}`,
|
||||
{
|
||||
headers: {
|
||||
authorization: `Bot ${context.env.BOT_TOKEN}`,
|
||||
@ -47,7 +47,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
{
|
||||
title: "Appeal Accepted",
|
||||
color: 0x00ff00,
|
||||
description: `Appeal from user ${metadata.tag} (${metadata.id}) was accepted.`,
|
||||
description: `Appeal from user ${appeal.username}#${appeal.discriminator} (${appeal.id}) was accepted.`,
|
||||
fields: [
|
||||
{
|
||||
name: "Moderator",
|
||||
|
@ -1,8 +1,8 @@
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const { metadata, value } = context.data.appeal;
|
||||
const { appeal } = context.data;
|
||||
const body = new FormData();
|
||||
body.append("from", "noreply@mail.carcrushers.cc");
|
||||
body.append("to", value.email);
|
||||
body.append("to", appeal.email);
|
||||
body.append("subject", "Appeal Denied");
|
||||
body.append("template", "appeal_denied");
|
||||
body.append("v:note", context.data.body.feedback || "No note provided.");
|
||||
@ -36,7 +36,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
{
|
||||
title: "Appeal Denied",
|
||||
color: 0xff0000,
|
||||
description: `Appeal from user ${metadata.tag} (${metadata.id}) was denied.`,
|
||||
description: `Appeal from user ${appeal.username}#${appeal.discriminator} (${appeal.id}) was denied.`,
|
||||
fields: [
|
||||
{
|
||||
name: "Moderator",
|
||||
|
Loading…
x
Reference in New Issue
Block a user