feat: multiple webhooks

pull/161/head
lyc8503 2025-11-04 23:53:10 +08:00
parent e757e1b970
commit 1b534c518a
2 changed files with 10 additions and 1 deletions

View File

@ -60,7 +60,7 @@ export type Notification = {
skipNotificationIds?: string[]
}
export type WebhookConfig = {
type SingleWebhook = {
url: string
method?: 'GET' | 'POST' | 'PUT' | 'PATCH'
headers?: { [key: string]: string | number }
@ -69,6 +69,8 @@ export type WebhookConfig = {
timeout?: number
}
export type WebhookConfig = SingleWebhook | SingleWebhook[]
export type Callbacks<TEnv = Env> = {
onStatusChange?: (
env: TEnv,

View File

@ -79,6 +79,13 @@ function templateWebhookPlayload(payload: any, message: string) {
}
async function webhookNotify(webhook: WebhookConfig, message: string) {
if (Array.isArray(webhook)) {
for (const w of webhook) {
webhookNotify(w, message)
}
return
}
console.log(
'Sending webhook notification: ' + JSON.stringify(message) + ' to webhook ' + webhook.url
)