do not fail when webhook endpoint doesn't exist
This commit is contained in:
parent
ccdf9b9bed
commit
ffc4dcf8f5
@ -1,4 +1,5 @@
|
|||||||
export async function webhookUserReported(endpoint: string, uuid: string) {
|
export async function webhookUserReported(endpoint: string, uuid: string) {
|
||||||
|
try {
|
||||||
await fetch(endpoint, {
|
await fetch(endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -8,4 +9,7 @@ export async function webhookUserReported(endpoint: string, uuid: string) {
|
|||||||
user: uuid
|
user: uuid
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
throw (e as { message: string }).message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,8 +153,12 @@ 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) {
|
||||||
|
console.error(`failed to send reported webhook: ${e}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user