Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Send webhook notifications for inactivity updates
  • Loading branch information
regalijan committed Feb 18, 2024
1 parent a275424 commit c3f89d8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions functions/api/inactivity/[id].ts
Expand Up @@ -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, {
status: 204,
});
Expand Down

0 comments on commit c3f89d8

Please sign in to comment.