Add an abstract json layout to make it's easier to change json library (#16528)

* Add an abstract json layout to make it's easier to change json library

* Fix import

* Fix import sequence

* Fix blank lines

* Fix blank lines
This commit is contained in:
Lunny Xiao 2021-07-25 00:03:58 +08:00 committed by GitHub
parent e0f9635c06
commit 9f31f3aa8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
93 changed files with 272 additions and 264 deletions

View file

@ -17,13 +17,13 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/services/forms"
"code.gitea.io/gitea/services/webhook"
jsoniter "github.com/json-iterator/go"
)
const (
@ -306,7 +306,6 @@ func DiscordHooksNewPost(ctx *context.Context) {
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.DiscordMeta{
Username: form.Username,
IconURL: form.IconURL,
@ -402,7 +401,6 @@ func TelegramHooksNewPost(ctx *context.Context) {
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.TelegramMeta{
BotToken: form.BotToken,
ChatID: form.ChatID,
@ -455,7 +453,6 @@ func MatrixHooksNewPost(ctx *context.Context) {
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.MatrixMeta{
HomeserverURL: form.HomeserverURL,
Room: form.RoomID,
@ -560,7 +557,6 @@ func SlackHooksNewPost(ctx *context.Context) {
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.SlackMeta{
Channel: strings.TrimSpace(form.Channel),
Username: form.Username,
@ -848,7 +844,6 @@ func SlackHooksEditPost(ctx *context.Context) {
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.SlackMeta{
Channel: strings.TrimSpace(form.Channel),
Username: form.Username,
@ -894,7 +889,6 @@ func DiscordHooksEditPost(ctx *context.Context) {
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.DiscordMeta{
Username: form.Username,
IconURL: form.IconURL,
@ -970,7 +964,7 @@ func TelegramHooksEditPost(ctx *context.Context) {
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.TelegramMeta{
BotToken: form.BotToken,
ChatID: form.ChatID,
@ -1012,7 +1006,7 @@ func MatrixHooksEditPost(ctx *context.Context) {
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
return
}
json := jsoniter.ConfigCompatibleWithStandardLibrary
meta, err := json.Marshal(&webhook.MatrixMeta{
HomeserverURL: form.HomeserverURL,
Room: form.RoomID,