diff options
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/models/webhook.go b/models/webhook.go index c7fcfba49e..9ad01f1b9d 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -7,7 +7,6 @@ package models import ( "context" - "encoding/json" "fmt" "strings" "time" @@ -18,6 +17,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" gouuid "github.com/google/uuid" + jsoniter "github.com/json-iterator/go" ) // HookContentType is the content type of a web hook @@ -145,6 +145,8 @@ type Webhook struct { // AfterLoad updates the webhook object upon setting a column func (w *Webhook) AfterLoad() { w.HookEvent = &HookEvent{} + + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil { log.Error("Unmarshal[%d]: %v", w.ID, err) } @@ -157,6 +159,7 @@ func (w *Webhook) History(page int) ([]*HookTask, error) { // UpdateEvent handles conversion from HookEvent to Events. func (w *Webhook) UpdateEvent() error { + json := jsoniter.ConfigCompatibleWithStandardLibrary data, err := json.Marshal(w.HookEvent) w.Events = string(data) return err @@ -689,6 +692,7 @@ func (t *HookTask) AfterLoad() { } t.RequestInfo = &HookRequest{} + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil { log.Error("Unmarshal RequestContent[%d]: %v", t.ID, err) } @@ -702,6 +706,7 @@ func (t *HookTask) AfterLoad() { } func (t *HookTask) simpleMarshalJSON(v interface{}) string { + json := jsoniter.ConfigCompatibleWithStandardLibrary p, err := json.Marshal(v) if err != nil { log.Error("Marshal [%d]: %v", t.ID, err) |