Send webhooks when inactivity notice is created
This commit is contained in:
parent
002cc6bb10
commit
c50cc97206
@ -48,6 +48,34 @@ export async function onRequestPost(context: RequestContext) {
|
||||
.bind(Date.now(), inactivityId, context.data.current_user.id)
|
||||
.run();
|
||||
|
||||
const departmentsToNotify = [];
|
||||
const { env } = context;
|
||||
|
||||
for (const department of departments)
|
||||
departmentsToNotify.push(env[`${department}_INACTIVITY_WEBHOOK`]);
|
||||
|
||||
const webhookPromises = [];
|
||||
for (const departmentWebhook of departmentsToNotify)
|
||||
webhookPromises.push(
|
||||
await fetch(departmentWebhook, {
|
||||
body: JSON.stringify({
|
||||
embeds: [
|
||||
{
|
||||
title: "Inactivity Notice Submitted",
|
||||
color: 3756250,
|
||||
description: `View this notice at https://carcrushers.cc/mod-queue?id=${inactivityId}&type=inactivity`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.allSettled(webhookPromises);
|
||||
|
||||
return new Response(null, {
|
||||
status: 204,
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user