diff --git a/src/lib/server/webhook.ts b/src/lib/server/webhook.ts index f2b7d67..d180d2b 100644 --- a/src/lib/server/webhook.ts +++ b/src/lib/server/webhook.ts @@ -1,11 +1,15 @@ export async function webhookUserReported(endpoint: string, uuid: string) { - await fetch(endpoint, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - user: uuid - }) - }); + try { + await fetch(endpoint, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + user: uuid + }) + }); + } catch (e) { + throw (e as { message: string }).message; + } } diff --git a/src/routes/admin/reports/+server.ts b/src/routes/admin/reports/+server.ts index 560dd7b..9f8e23f 100644 --- a/src/routes/admin/reports/+server.ts +++ b/src/routes/admin/reports/+server.ts @@ -153,8 +153,12 @@ export const PATCH = (async ({ request, cookies }) => { if (webhookTriggerUsers.length > 0 && data.status == 'reviewed' && env.REPORTED_WEBHOOK) { for (const webhookTriggerUser of webhookTriggerUsers) { - // no `await` to avoid blocking - webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser); + try { + // no `await` to avoid blocking + webhookUserReported(env.REPORTED_WEBHOOK, webhookTriggerUser); + } catch (e) { + console.error(`failed to send reported webhook: ${e}`); + } } }