Send webhook notifications for inactivity updates

This commit is contained in:
2024-02-18 18:28:02 -05:00
parent a275424316
commit c3f89d86db

View File

@ -157,6 +157,32 @@ export async function onRequestPut(context: RequestContext) {
}, },
); );
const departmentWebhooks = [];
for (const department of departments)
departmentWebhooks.push(context.env[`${department}_INACTIVITY_WEBHOOK`]);
const webhookPromises = [];
for (const webhook of departmentWebhooks)
webhookPromises.push(
fetch(webhook, {
body: JSON.stringify({
embeds: [
{
title: "Inactivity Notice Modified",
color: 37562560,
description: `View the updated notice at https://carcrushers.cc/mod-queue?id=${context.params.id}&type=inactivity`,
},
],
}),
headers: {
"content-type": "application/json",
},
method: "POST",
}),
);
await Promise.allSettled(webhookPromises);
return new Response(null, { return new Response(null, {
status: 204, status: 204,
}); });