summaryrefslogtreecommitdiffstats
path: root/models/webhook.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-08-30 13:36:52 +0800
committerGitHub <noreply@github.com>2017-08-30 13:36:52 +0800
commit04ec79579cdcd5cf647ef3ff33d35ecfa7550b49 (patch)
tree261ba09b42fe1eb7af4b215b3c2360f8593ada20 /models/webhook.go
parent5de94a67cf09ae21254269058d86f71fe05ea243 (diff)
downloadgitea-04ec79579cdcd5cf647ef3ff33d35ecfa7550b49.tar.gz
gitea-04ec79579cdcd5cf647ef3ff33d35ecfa7550b49.zip
fix orgnization webhooks (#2422)
* fix org webhooks * remove trace code
Diffstat (limited to 'models/webhook.go')
-rw-r--r--models/webhook.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/models/webhook.go b/models/webhook.go
index 5ad27ee8f3..9e5742cb52 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -221,6 +221,13 @@ func getWebhook(bean *Webhook) (*Webhook, error) {
return bean, nil
}
+// GetWebhookByID returns webhook of repository by given ID.
+func GetWebhookByID(id int64) (*Webhook, error) {
+ return getWebhook(&Webhook{
+ ID: id,
+ })
+}
+
// GetWebhookByRepoID returns webhook of repository by given ID.
func GetWebhookByRepoID(repoID, id int64) (*Webhook, error) {
return getWebhook(&Webhook{
@@ -271,6 +278,12 @@ func UpdateWebhook(w *Webhook) error {
return err
}
+// UpdateWebhookLastStatus updates last status of webhook.
+func UpdateWebhookLastStatus(w *Webhook) error {
+ _, err := x.ID(w.ID).Cols("last_status").Update(w)
+ return err
+}
+
// deleteWebhook uses argument bean as query condition,
// ID must be specified and do not assign unnecessary fields.
func deleteWebhook(bean *Webhook) (err error) {
@@ -603,7 +616,7 @@ func (t *HookTask) deliver() {
}
// Update webhook last delivery status.
- w, err := GetWebhookByRepoID(t.RepoID, t.HookID)
+ w, err := GetWebhookByID(t.HookID)
if err != nil {
log.Error(5, "GetWebhookByID: %v", err)
return
@@ -613,8 +626,8 @@ func (t *HookTask) deliver() {
} else {
w.LastStatus = HookStatusFail
}
- if err = UpdateWebhook(w); err != nil {
- log.Error(5, "UpdateWebhook: %v", err)
+ if err = UpdateWebhookLastStatus(w); err != nil {
+ log.Error(5, "UpdateWebhookLastStatus: %v", err)
return
}
}()