Skip to content

Commit d5f812d

Browse files
committed
Fix bug for webhook
1 parent c11cf4b commit d5f812d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

models/webhook.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package models
88
import (
99
"encoding/json"
1010
"fmt"
11+
"strings"
1112
"time"
1213

1314
"code.gitea.io/gitea/modules/log"
@@ -310,6 +311,7 @@ func CreateWebhook(w *Webhook) error {
310311
}
311312

312313
func createWebhook(e Engine, w *Webhook) error {
314+
w.Type = strings.TrimSpace(w.Type)
313315
_, err := e.Insert(w)
314316
return err
315317
}
@@ -547,7 +549,7 @@ func copyDefaultWebhooksToRepo(e Engine, repoID int64) error {
547549
// \/ \/ \/ \/ \/
548550

549551
// HookTaskType is the type of an hook task
550-
type HookTaskType string
552+
type HookTaskType = string
551553

552554
// Types of hook tasks
553555
const (

services/webhook/webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func prepareWebhook(w *models.Webhook, repo *models.Repository, event models.Hoo
144144

145145
var payloader api.Payloader
146146
var err error
147-
webhook, ok := webhooks[w.Type]
147+
webhook, ok := webhooks[strings.TrimSpace(w.Type)] // NOTICE: w.Type maynot be trimmed before store into database
148148
if ok {
149149
payloader, err = webhook.payloadCreator(p, event, w.Meta)
150150
if err != nil {

0 commit comments

Comments
 (0)