Permalink
Newer
100644
73 lines (66 sloc)
1.91 KB
3
const body = new FormData();
4
body.append("from", "noreply@mail.carcrushers.cc");
6
body.append("subject", "Appeal Accepted");
7
body.append("template", "appeal_accepted");
8
body.append("v:note", context.data.body.feedback || "No note provided.");
9
10
const emailReq = await fetch(
11
"https://api.mailgun.net/v3/mail.carcrushers.cc/messages",
12
{
13
body,
14
headers: {
15
authorization: `Basic ${btoa("api:" + context.env.MAILGUN_API_KEY)}`,
16
},
17
method: "POST",
19
);
20
21
if (!emailReq.ok) {
22
console.log(await emailReq.json());
23
return new Response('{"error":"Failed to accept appeal"}', {
24
headers: {
25
"content-type": "application/json",
26
},
27
status: 500,
28
});
29
}
30
31
const { current_user: currentUser } = context.data;
32
33
await context.env.D1.prepare("UPDATE appeals SET open = 0 WHERE id = ?;")
34
.bind(context.params.id)
35
.run();
36
38
`https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.id}`,
42
"x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})`,
46
);
47
48
await fetch(context.env.APPEALS_WEBHOOK, {
49
body: JSON.stringify({
50
embeds: [
51
{
52
title: "Appeal Accepted",
53
color: 0x00ff00,
54
description: `Appeal from user ${appeal.user.username} (${appeal.user.id}) was accepted.`,