1
0
Fork 0
forked from forgejo/forgejo

add organization-level webhooks

This commit is contained in:
Christopher Brickley 2014-09-04 07:17:00 -04:00
parent 7269b06fd5
commit 85c35a6b8b
12 changed files with 208 additions and 24 deletions

View file

@ -45,6 +45,7 @@ type Webhook struct {
IsActive bool
HookTaskType HookTaskType
Meta string `xorm:"TEXT"` // store hook-specific attributes
OrgId int64
}
// GetEvent handles conversion from Events to HookEvent.
@ -120,6 +121,18 @@ func DeleteWebhook(hookId int64) error {
return err
}
// GetWebhooksByOrgId returns all webhooks for an organization.
func GetWebhooksByOrgId(orgId int64) (ws []*Webhook, err error) {
err = x.Find(&ws, &Webhook{OrgId: orgId})
return ws, err
}
// GetActiveWebhooksByOrgId returns all active webhooks for an organization.
func GetActiveWebhooksByOrgId(orgId int64) (ws []*Webhook, err error) {
err = x.Find(&ws, &Webhook{OrgId: orgId, IsActive: true})
return ws, err
}
// ___ ___ __ ___________ __
// / | \ ____ ____ | | _\__ ___/____ _____| | __
// / ~ \/ _ \ / _ \| |/ / | | \__ \ / ___/ |/ /