forked from forgejo/forgejo
Add Gitea Webhook (#1755)
* Replace Gogs by Gitea * Fix missing changes * Create Gitea webhook and put Gogs webhook apart.
This commit is contained in:
parent
e67ece26f0
commit
e0c6ab2d44
11 changed files with 167 additions and 12 deletions
|
@ -1,4 +1,5 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -312,9 +313,11 @@ type HookTaskType int
|
|||
const (
|
||||
GOGS HookTaskType = iota + 1
|
||||
SLACK
|
||||
GITEA
|
||||
)
|
||||
|
||||
var hookTaskTypes = map[string]HookTaskType{
|
||||
"gitea": GITEA,
|
||||
"gogs": GOGS,
|
||||
"slack": SLACK,
|
||||
}
|
||||
|
@ -327,6 +330,8 @@ func ToHookTaskType(name string) HookTaskType {
|
|||
// Name returns the name of an hook task type
|
||||
func (t HookTaskType) Name() string {
|
||||
switch t {
|
||||
case GITEA:
|
||||
return "gitea"
|
||||
case GOGS:
|
||||
return "gogs"
|
||||
case SLACK:
|
||||
|
@ -503,7 +508,7 @@ func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) err
|
|||
}
|
||||
}
|
||||
|
||||
// Use separate objects so modifications 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/Gitea type hooks.
|
||||
switch w.HookTaskType {
|
||||
case SLACK:
|
||||
payloader, err = GetSlackPayload(p, event, w.Meta)
|
||||
|
@ -536,6 +541,8 @@ func (t *HookTask) deliver() {
|
|||
|
||||
timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second
|
||||
req := httplib.Post(t.URL).SetTimeout(timeout, timeout).
|
||||
Header("X-Gitea-Delivery", t.UUID).
|
||||
Header("X-Gitea-Event", string(t.EventType)).
|
||||
Header("X-Gogs-Delivery", t.UUID).
|
||||
Header("X-Gogs-Event", string(t.EventType)).
|
||||
Header("X-GitHub-Delivery", t.UUID).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue