feat: multiple webhooks
parent
e757e1b970
commit
1b534c518a
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue