fix crashing webhook sending

This commit is contained in:
bytedream 2024-12-20 20:46:48 +01:00
parent 0280e2a277
commit 8e60f83b6f

View File

@ -50,12 +50,7 @@ export const POST = (async ({ request, cookies }) => {
let reports = await Report.findAll({ let reports = await Report.findAll({
where: reportFindOptions, where: reportFindOptions,
include: [ include: [{ all: true }],
{ model: User, as: 'reporter' },
{ model: User, as: 'reported' },
{ model: Admin, as: 'auditor' },
{ model: StrikeReason, as: 'strike_reason' }
],
order: [['created_at', 'DESC']], order: [['created_at', 'DESC']],
offset: data.from || 0, offset: data.from || 0,
limit: data.limit || 100 limit: data.limit || 100
@ -153,12 +148,10 @@ export const PATCH = (async ({ request, cookies }) => {
if (webhookTriggerUsers.length > 0 && data.status == 'reviewed' && env.REPORTED_WEBHOOK) { if (webhookTriggerUsers.length > 0 && data.status == 'reviewed' && env.REPORTED_WEBHOOK) {
for (const webhookTriggerUser of webhookTriggerUsers) { for (const webhookTriggerUser of webhookTriggerUsers) {
try {
// no `await` to avoid blocking // no `await` to avoid blocking
webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser); webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser).catch((e) =>
} catch (e) { console.error(`failed to send reported webhook: ${e}`)
console.error(`failed to send reported webhook: ${e}`); );
}
} }
} }