Move most email sending to common email function

This commit is contained in:
2023-10-19 16:51:00 -04:00
parent 86109eb770
commit b5a92db954
3 changed files with 37 additions and 31 deletions

View File

@ -1,6 +1,7 @@
import { getBanList, setBanList } from "../../../roblox-open-cloud.js";
import { GetAccessToken, insertLogs } from "../../../gcloud.js";
import { jsonError } from "../../../common.js";
import sendEmail from "../../../email.js";
export async function onRequestPost(context: RequestContext) {
const reportId = context.params.id as string;
@ -14,6 +15,18 @@ export async function onRequestPost(context: RequestContext) {
const actionMap = context.data.body;
const newActions: { [k: string]: { BanType: number } } = {};
const logMap: { [k: string]: number } = {};
const { user } = reportData as ReportCardProps & { user?: { email: string } };
if (user?.email)
await sendEmail(
user.email,
context.env.MAILGUN_API_KEY,
"Report Processed",
"report_processed",
{
username: reportData.user?.username as string,
},
);
if (!Object.values(actionMap).find((action) => action !== 0)) {
await context.env.DATA.delete(`report_${reportId}`);