diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-06 11:50:31 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-06 11:50:31 -0400 |
commit | e573855a4f040abd4aa6a2afa9ce610a1ec2670f (patch) | |
tree | 7ead7dafd3c228305e83a19dec0bca5b60d92217 /models/webhook.go | |
parent | 94bccbb148a4ed897eb8332fc746aa75486c5c4d (diff) | |
download | gitea-e573855a4f040abd4aa6a2afa9ce610a1ec2670f.tar.gz gitea-e573855a4f040abd4aa6a2afa9ce610a1ec2670f.zip |
Fix #98, support web hook
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/models/webhook.go b/models/webhook.go index daa4510f2d..f10fa2131e 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -28,7 +28,7 @@ type HookEvent struct { type Webhook struct { Id int64 RepoId int64 - Payload string `xorm:"TEXT"` + Url string `xorm:"TEXT"` ContentType int Secret string `xorm:"TEXT"` Events string `xorm:"TEXT"` @@ -50,6 +50,13 @@ func (w *Webhook) SaveEvent() error { return err } +func (w *Webhook) HasPushEvent() bool { + if w.PushOnly { + return true + } + return false +} + // CreateWebhook creates new webhook. func CreateWebhook(w *Webhook) error { _, err := orm.Insert(w) @@ -74,6 +81,12 @@ func GetWebhookById(hookId int64) (*Webhook, error) { return w, nil } +// GetActiveWebhooksByRepoId returns all active webhooks of repository. +func GetActiveWebhooksByRepoId(repoId int64) (ws []*Webhook, err error) { + err = orm.Find(&ws, &Webhook{RepoId: repoId, IsActive: true}) + return ws, err +} + // GetWebhooksByRepoId returns all webhooks of repository. func GetWebhooksByRepoId(repoId int64) (ws []*Webhook, err error) { err = orm.Find(&ws, &Webhook{RepoId: repoId}) |