|
@@ -9,13 +9,13 @@ import (
|
|
"crypto/sha256"
|
|
"crypto/sha256"
|
|
"crypto/tls"
|
|
"crypto/tls"
|
|
"encoding/hex"
|
|
"encoding/hex"
|
|
- "encoding/json"
|
|
|
|
"fmt"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/go-xorm/xorm"
|
|
"github.com/go-xorm/xorm"
|
|
|
|
+ "github.com/json-iterator/go"
|
|
gouuid "github.com/satori/go.uuid"
|
|
gouuid "github.com/satori/go.uuid"
|
|
log "gopkg.in/clog.v1"
|
|
log "gopkg.in/clog.v1"
|
|
|
|
|
|
@@ -126,7 +126,7 @@ func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
|
|
switch colName {
|
|
switch colName {
|
|
case "events":
|
|
case "events":
|
|
w.HookEvent = &HookEvent{}
|
|
w.HookEvent = &HookEvent{}
|
|
- if err = json.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
|
|
|
|
|
|
+ if err = jsoniter.Unmarshal([]byte(w.Events), w.HookEvent); err != nil {
|
|
log.Error(3, "Unmarshal [%d]: %v", w.ID, err)
|
|
log.Error(3, "Unmarshal [%d]: %v", w.ID, err)
|
|
}
|
|
}
|
|
case "created_unix":
|
|
case "created_unix":
|
|
@@ -138,7 +138,7 @@ func (w *Webhook) AfterSet(colName string, _ xorm.Cell) {
|
|
|
|
|
|
func (w *Webhook) GetSlackHook() *SlackMeta {
|
|
func (w *Webhook) GetSlackHook() *SlackMeta {
|
|
s := &SlackMeta{}
|
|
s := &SlackMeta{}
|
|
- if err := json.Unmarshal([]byte(w.Meta), s); err != nil {
|
|
|
|
|
|
+ if err := jsoniter.Unmarshal([]byte(w.Meta), s); err != nil {
|
|
log.Error(2, "GetSlackHook [%d]: %v", w.ID, err)
|
|
log.Error(2, "GetSlackHook [%d]: %v", w.ID, err)
|
|
}
|
|
}
|
|
return s
|
|
return s
|
|
@@ -151,7 +151,7 @@ func (w *Webhook) History(page int) ([]*HookTask, error) {
|
|
|
|
|
|
// UpdateEvent handles conversion from HookEvent to Events.
|
|
// UpdateEvent handles conversion from HookEvent to Events.
|
|
func (w *Webhook) UpdateEvent() error {
|
|
func (w *Webhook) UpdateEvent() error {
|
|
- data, err := json.Marshal(w.HookEvent)
|
|
|
|
|
|
+ data, err := jsoniter.Marshal(w.HookEvent)
|
|
w.Events = string(data)
|
|
w.Events = string(data)
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
@@ -456,7 +456,7 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) {
|
|
}
|
|
}
|
|
|
|
|
|
t.RequestInfo = &HookRequest{}
|
|
t.RequestInfo = &HookRequest{}
|
|
- if err = json.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
|
|
|
|
|
|
+ if err = jsoniter.Unmarshal([]byte(t.RequestContent), t.RequestInfo); err != nil {
|
|
log.Error(3, "Unmarshal[%d]: %v", t.ID, err)
|
|
log.Error(3, "Unmarshal[%d]: %v", t.ID, err)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -466,14 +466,14 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) {
|
|
}
|
|
}
|
|
|
|
|
|
t.ResponseInfo = &HookResponse{}
|
|
t.ResponseInfo = &HookResponse{}
|
|
- if err = json.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil {
|
|
|
|
|
|
+ if err = jsoniter.Unmarshal([]byte(t.ResponseContent), t.ResponseInfo); err != nil {
|
|
log.Error(3, "Unmarshal [%d]: %v", t.ID, err)
|
|
log.Error(3, "Unmarshal [%d]: %v", t.ID, err)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
func (t *HookTask) MarshalJSON(v interface{}) string {
|
|
func (t *HookTask) MarshalJSON(v interface{}) string {
|
|
- p, err := json.Marshal(v)
|
|
|
|
|
|
+ p, err := jsoniter.Marshal(v)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Error(3, "Marshal [%d]: %v", t.ID, err)
|
|
log.Error(3, "Marshal [%d]: %v", t.ID, err)
|
|
}
|
|
}
|