generated from nhcarrigan/template
chore: cleanup
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 30s
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 30s
This commit is contained in:
@ -129,40 +129,40 @@ export const instantiateServer = (): void => {
|
||||
"x-signature-timestamp": string;
|
||||
}; }>(
|
||||
"/entitlement",
|
||||
// eslint-disable-next-line complexity -- Fuck off.
|
||||
async(request, response) => {
|
||||
const { type, application_id: applicationId, event } = request.body;
|
||||
const appInfo = applicationData[applicationId];
|
||||
const isValid = await validateWebhook(request);
|
||||
if (!isValid) {
|
||||
await response.status(401).send({ success: false });
|
||||
void sendDiscord(
|
||||
"[NOTIFICATION]: Entitlement Event",
|
||||
`[ENTITLEMENT]: ${appInfo?.name ?? applicationId}`,
|
||||
"An invalid webhook signature was received.",
|
||||
);
|
||||
void sendMail(
|
||||
"[NOTIFICATION]: Entitlement Event",
|
||||
`[ENTITLEMENT]: ${appInfo?.name ?? applicationId}`,
|
||||
"An invalid webhook signature was received.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
await response.status(204).send();
|
||||
const { type } = request.body;
|
||||
if (type === 0) {
|
||||
void sendDiscord(
|
||||
"[NOTIFICATION]: Entitlement Event",
|
||||
`[ENTITLEMENT]: ${appInfo?.name ?? applicationId}`,
|
||||
"Received a ping from Discord.",
|
||||
);
|
||||
void sendMail(
|
||||
"[NOTIFICATION]: Entitlement Event",
|
||||
`[ENTITLEMENT]: ${appInfo?.name ?? applicationId}`,
|
||||
"Received a ping from Discord.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
const { application_id: applicationId, event } = request.body;
|
||||
const {
|
||||
user_id: userId,
|
||||
guild_id: guildId,
|
||||
ends_at: endsAt,
|
||||
} = event.data;
|
||||
const appInfo = applicationData[applicationId];
|
||||
await sendDiscord(
|
||||
`[ENTITLEMENT]: ${appInfo?.name ?? applicationId}`,
|
||||
`Entitlement purchased!\n- **User ID**: ${userId}\n- **Guild ID**: ${guildId}\n- **Ends At**: ${endsAt}`,
|
||||
|
Reference in New Issue
Block a user