mirror of https://github.com/go-gitea/gitea.git
fix orgnization webhooks (#2422)
* fix org webhooks * remove trace code
This commit is contained in:
parent
5de94a67cf
commit
04ec79579c
|
@ -221,6 +221,13 @@ func getWebhook(bean *Webhook) (*Webhook, error) {
|
||||||
return bean, nil
|
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.
|
// GetWebhookByRepoID returns webhook of repository by given ID.
|
||||||
func GetWebhookByRepoID(repoID, id int64) (*Webhook, error) {
|
func GetWebhookByRepoID(repoID, id int64) (*Webhook, error) {
|
||||||
return getWebhook(&Webhook{
|
return getWebhook(&Webhook{
|
||||||
|
@ -271,6 +278,12 @@ func UpdateWebhook(w *Webhook) error {
|
||||||
return err
|
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,
|
// deleteWebhook uses argument bean as query condition,
|
||||||
// ID must be specified and do not assign unnecessary fields.
|
// ID must be specified and do not assign unnecessary fields.
|
||||||
func deleteWebhook(bean *Webhook) (err error) {
|
func deleteWebhook(bean *Webhook) (err error) {
|
||||||
|
@ -603,7 +616,7 @@ func (t *HookTask) deliver() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update webhook last delivery status.
|
// Update webhook last delivery status.
|
||||||
w, err := GetWebhookByRepoID(t.RepoID, t.HookID)
|
w, err := GetWebhookByID(t.HookID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(5, "GetWebhookByID: %v", err)
|
log.Error(5, "GetWebhookByID: %v", err)
|
||||||
return
|
return
|
||||||
|
@ -613,8 +626,8 @@ func (t *HookTask) deliver() {
|
||||||
} else {
|
} else {
|
||||||
w.LastStatus = HookStatusFail
|
w.LastStatus = HookStatusFail
|
||||||
}
|
}
|
||||||
if err = UpdateWebhook(w); err != nil {
|
if err = UpdateWebhookLastStatus(w); err != nil {
|
||||||
log.Error(5, "UpdateWebhook: %v", err)
|
log.Error(5, "UpdateWebhookLastStatus: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -142,8 +142,6 @@ func getDiscordPushPayload(p *api.PushPayload, meta *DiscordMeta) (*DiscordPaylo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(text)
|
|
||||||
|
|
||||||
return &DiscordPayload{
|
return &DiscordPayload{
|
||||||
Username: meta.Username,
|
Username: meta.Username,
|
||||||
AvatarURL: meta.IconURL,
|
AvatarURL: meta.IconURL,
|
||||||
|
|
|
@ -396,7 +396,7 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
|
m.Post("/gitea/new", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksNewPost)
|
||||||
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
|
m.Post("/gogs/new", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksNewPost)
|
||||||
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
|
m.Post("/slack/new", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksNewPost)
|
||||||
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksEditPost)
|
m.Post("/discord/new", bindIgnErr(auth.NewDiscordHookForm{}), repo.DiscordHooksNewPost)
|
||||||
m.Get("/:id", repo.WebHooksEdit)
|
m.Get("/:id", repo.WebHooksEdit)
|
||||||
m.Post("/gitea/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
m.Post("/gitea/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost)
|
||||||
m.Post("/gogs/:id", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksEditPost)
|
m.Post("/gogs/:id", bindIgnErr(auth.NewGogshookForm{}), repo.GogsHooksEditPost)
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
{{template "repo/settings/hook_gitea" .}}
|
{{template "repo/settings/hook_gitea" .}}
|
||||||
{{template "repo/settings/hook_gogs" .}}
|
{{template "repo/settings/hook_gogs" .}}
|
||||||
{{template "repo/settings/hook_slack" .}}
|
{{template "repo/settings/hook_slack" .}}
|
||||||
|
{{template "repo/settings/hook_discord" .}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{template "repo/settings/hook_history" .}}
|
{{template "repo/settings/hook_history" .}}
|
||||||
|
|
Loading…
Reference in New Issue