Permalink
Newer
100644
83 lines (73 sloc)
2.1 KB
9
await sendPushNotification(
10
context.env,
11
"Appeal Accepted",
12
context.data.body.feedback || "No additional details to display",
15
16
await context.env.D1.prepare(
17
"DELETE FROM push_notifications WHERE event_id = ? AND event_type = 'appeal';",
18
)
19
.bind(appeal.id)
20
.run();
21
} else {
22
const emailResponse = await sendEmail(
23
appeal.user.email,
24
context.env.MAILGUN_API_KEY,
25
"Appeal Accepted",
26
"appeal_accepted",
27
{
30
);
31
32
if (!emailResponse.ok) {
33
console.log(await emailResponse.json());
34
return jsonError("Failed to accept appeal", 500);
35
}
41
"UPDATE appeals SET approved = 1, user = json_remove(user, '$.email') WHERE id = ?;",
48
`https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.user.id}`,
52
"x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})`,
56
);
57
58
await fetch(context.env.APPEALS_WEBHOOK, {
59
body: JSON.stringify({
60
embeds: [
61
{
62
title: "Appeal Accepted",
63
color: 0x00ff00,
64
description: `Appeal from user ${appeal.user.username} (${appeal.user.id}) was accepted.`,