diff options
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/models/webhook.go b/models/webhook.go index 8f5c561939..4dd10b0c79 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -231,10 +231,8 @@ func GetWebhookByOrgID(orgID, id int64) (*Webhook, error) { // GetActiveWebhooksByRepoID returns all active webhooks of repository. func GetActiveWebhooksByRepoID(repoID int64) ([]*Webhook, error) { webhooks := make([]*Webhook, 0, 5) - return webhooks, x.Find(&webhooks, &Webhook{ - RepoID: repoID, - IsActive: true, - }) + return webhooks, x.Where("is_active=?", true). + Find(&webhooks, &Webhook{RepoID: repoID}) } // GetWebhooksByRepoID returns all webhooks of a repository. @@ -243,6 +241,21 @@ func GetWebhooksByRepoID(repoID int64) ([]*Webhook, error) { return webhooks, x.Find(&webhooks, &Webhook{RepoID: repoID}) } +// GetActiveWebhooksByOrgID returns all active webhooks for an organization. +func GetActiveWebhooksByOrgID(orgID int64) (ws []*Webhook, err error) { + err = x. + Where("org_id=?", orgID). + And("is_active=?", true). + Find(&ws) + return ws, 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 +} + // UpdateWebhook updates information of webhook. func UpdateWebhook(w *Webhook) error { _, err := x.Id(w.ID).AllCols().Update(w) @@ -285,21 +298,6 @@ func DeleteWebhookByOrgID(orgID, id int64) error { }) } -// 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. - Where("org_id=?", orgID). - And("is_active=?", true). - Find(&ws) - return ws, err -} - // ___ ___ __ ___________ __ // / | \ ____ ____ | | _\__ ___/____ _____| | __ // / ~ \/ _ \ / _ \| |/ / | | \__ \ / ___/ |/ / @@ -505,7 +503,7 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err } } - // Use separate objects so modifcations won't be made on payload on non-Gogs type hooks. + // Use separate objects so modifications won't be made on payload on non-Gogs type hooks. switch w.HookTaskType { case SLACK: payloader, err = GetSlackPayload(p, event, w.Meta) |