diff options
Diffstat (limited to 'services/webhook/matrix.go')
-rw-r--r-- | services/webhook/matrix.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/services/webhook/matrix.go b/services/webhook/matrix.go index 063147198a..1658dd4b44 100644 --- a/services/webhook/matrix.go +++ b/services/webhook/matrix.go @@ -6,7 +6,6 @@ package webhook import ( "crypto/sha1" - "encoding/json" "errors" "fmt" "html" @@ -19,6 +18,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" + jsoniter "github.com/json-iterator/go" ) const matrixPayloadSizeLimit = 1024 * 64 @@ -39,6 +39,7 @@ var messageTypeText = map[int]string{ // GetMatrixHook returns Matrix metadata func GetMatrixHook(w *models.Webhook) *MatrixMeta { s := &MatrixMeta{} + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(w.Meta), s); err != nil { log.Error("webhook.GetMatrixHook(%d): %v", w.ID, err) } @@ -80,6 +81,7 @@ func (m *MatrixPayloadUnsafe) SetSecret(_ string) {} // JSONPayload Marshals the MatrixPayloadUnsafe to json func (m *MatrixPayloadUnsafe) JSONPayload() ([]byte, error) { + json := jsoniter.ConfigCompatibleWithStandardLibrary data, err := json.MarshalIndent(m, "", " ") if err != nil { return []byte{}, err @@ -229,6 +231,7 @@ func GetMatrixPayload(p api.Payloader, event models.HookEventType, meta string) s := new(MatrixPayloadUnsafe) matrix := &MatrixMeta{} + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(meta), &matrix); err != nil { return s, errors.New("GetMatrixPayload meta json:" + err.Error()) } @@ -262,6 +265,7 @@ func getMessageBody(htmlText string) string { // The access_token is removed from t.PayloadContent func getMatrixHookRequest(t *models.HookTask) (*http.Request, error) { payloadunsafe := MatrixPayloadUnsafe{} + json := jsoniter.ConfigCompatibleWithStandardLibrary if err := json.Unmarshal([]byte(t.PayloadContent), &payloadunsafe); err != nil { log.Error("Matrix Hook delivery failed: %v", err) return nil, err |