fix: must use json marshal to convert to bytes, then unmarshal to a map
This commit is contained in:
parent
ae9b036cb5
commit
e907aa7e99
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"git.lumeweb.com/LumeWeb/gitea-github-proxy/config"
|
||||
"git.lumeweb.com/LumeWeb/gitea-github-proxy/db/model"
|
||||
"github.com/fatih/structs"
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
"io"
|
||||
|
@ -46,13 +45,24 @@ func (whm *WebhookManager) sendWebhooks(request interface{}, r *http.Request) {
|
|||
for _, app := range apps {
|
||||
go func(app model.Apps) {
|
||||
|
||||
rawMap := structs.New(request).Map()
|
||||
payloadBytes, err := json.Marshal(request)
|
||||
if err != nil {
|
||||
whm.logger.Error("Failed to marshal payload", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
var rawMap map[string]interface{}
|
||||
err = json.Unmarshal(payloadBytes, &rawMap)
|
||||
if err != nil {
|
||||
whm.logger.Error("Failed to unmarshal payload", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
rawMap["installation"] = struct {
|
||||
ID uint `json:"id"`
|
||||
}{ID: app.ID}
|
||||
|
||||
payloadBytes, err := json.Marshal(rawMap)
|
||||
payloadBytes, err = json.Marshal(request)
|
||||
if err != nil {
|
||||
whm.logger.Error("Failed to marshal payload", zap.Error(err))
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue