Add isEnabled to webhook.

This commit is contained in:
Yang Luo
2021-12-26 21:02:56 +08:00
parent 0c665edcbc
commit 9943e3c316
13 changed files with 95 additions and 25 deletions

View File

@ -146,6 +146,10 @@ func GetRecordsByField(record *Record) []*Record {
func SendWebhooks(record *Record) error {
webhooks := getWebhooksByOrganization(record.Organization)
for _, webhook := range webhooks {
if !webhook.IsEnabled {
continue
}
matched := false
for _, event := range webhook.Events {
if record.Action == event {

View File

@ -38,6 +38,7 @@ type Webhook struct {
ContentType string `xorm:"varchar(100)" json:"contentType"`
Headers []*Header `xorm:"mediumtext" json:"headers"`
Events []string `xorm:"varchar(100)" json:"events"`
IsEnabled bool `json:"isEnabled"`
}
func GetWebhookCount(owner, field, value string) int {