app
components
data
functions
api
admin-apps
submit.ts
appeals
auth
data-transfers
events-team
game-appeals
game-bans
gme
inactivity
infractions
me
mod-queue
notifications
reports
uploads
webview-captcha.ts
_middleware.ts
common.ts
email.ts
gcloud.ts
permissions.ts
roblox-open-cloud.ts
public
.gitignore
.node-version
.prettierignore
OFL.txt
emotion-server.js
index.css
index.d.ts
package-lock.json
package.json
remix.config.js
server.ts
theme.ts
tsconfig.json
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
export async function onRequest(context: RequestContext) {
|
|
const { current_user: currentUser } = context.data;
|
|
|
|
if (!currentUser.email)
|
|
return new Response(null, {
|
|
status: 204,
|
|
});
|
|
|
|
const deliveryDate = new Date(
|
|
Date.now() + 86400000 + Math.round(Math.random() * 172800000),
|
|
)
|
|
.toUTCString()
|
|
.replace("GMT", "+0000");
|
|
|
|
const emailData = new FormData();
|
|
emailData.append("from", "totallyrealadminapplication@mail.carcrushers.cc");
|
|
emailData.append("to", currentUser.email);
|
|
emailData.append("subject", "Your admin application has been approved");
|
|
emailData.append("o:deliverytime", deliveryDate);
|
|
emailData.append("v:username", currentUser.username);
|
|
emailData.append("template", "admin_application");
|
|
|
|
await fetch("https://api.mailgun.net/v3/mail.carcrushers.cc/messages", {
|
|
body: emailData,
|
|
headers: {
|
|
authorization: `Basic ${btoa(`api:${context.env.MAILGUN_API_KEY}`)}`,
|
|
},
|
|
method: "POST",
|
|
});
|
|
|
|
return new Response(null, {
|
|
status: 204,
|
|
});
|
|
}
|