feat: multiple webhooks

This commit is contained in:
lyc8503 committed 2025-11-04 23:53:10 +08:00
1 parent e757e1b970
commit 1b534c518a
2 files changed
+10 -1

No files matched your search

+3 -1
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,
+7
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
)