Permalink
Newer
100644
85 lines (74 sloc)
2.1 KB
8
if (appeal.fcm_token) {
9
await sendPushNotification(
10
context.env,
11
"Appeal Accepted",
12
context.data.body.feedback || "No additional details to display",
13
appeal.fcm_token,
14
);
15
} else {
16
const emailResponse = await sendEmail(
17
appeal.user.email,
18
context.env.MAILGUN_API_KEY,
19
"Appeal Accepted",
20
"appeal_accepted",
21
{
22
note: context.data.body.feedback || "No note provided.",
23
},
24
);
25
26
if (!emailResponse.ok) {
27
console.log(await emailResponse.json());
28
return jsonError("Failed to accept appeal", 500);
29
}
34
await context.env.D1.prepare(
35
"UPDATE appeals SET approved = 1, open = 0 WHERE id = ?;",
36
)
45
await context.env.DATA.put(`appeal_${appeal.id}`, JSON.stringify(appeal), {
46
expirationTtl: 94608000,
47
});
48
50
`https://discord.com/api/v10/guilds/242263977986359297/bans/${appeal.id}`,
54
"x-audit-log-reason": `Appeal accepted by ${currentUser.username} (${currentUser.id})`,
58
);
59
60
await fetch(context.env.APPEALS_WEBHOOK, {
61
body: JSON.stringify({
62
embeds: [
63
{
64
title: "Appeal Accepted",
65
color: 0x00ff00,
66
description: `Appeal from user ${appeal.user.username} (${appeal.user.id}) was accepted.`,