diff options
author | 无闻 <joe2010xtmf@163.com> | 2014-09-07 19:30:51 -0400 |
---|---|---|
committer | 无闻 <joe2010xtmf@163.com> | 2014-09-07 19:30:51 -0400 |
commit | e79e4b158090bf7c5dd86ac21cd0dbf44fbc82bd (patch) | |
tree | aec4d8a53265080363b3ab7a4423bc0820133ea5 /models/webhook.go | |
parent | 40bc130b19cf71a997d5073a2587ea2649128bf8 (diff) | |
parent | f7be61c81935a30c21797351db5da32183e3188d (diff) |
Merge pull request #442 from compressed/org_hook
Organization-level Webhooks
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/models/webhook.go b/models/webhook.go index 0b7b3a99..5acc83f5 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -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 +} + // ___ ___ __ ___________ __ // / | \ ____ ____ | | _\__ ___/____ _____| | __ // / ~ \/ _ \ / _ \| |/ / | | \__ \ / ___/ |/ / |