diff --git a/api/webhook_manager.go b/api/webhook_manager.go index 7e6c025..e8c230c 100644 --- a/api/webhook_manager.go +++ b/api/webhook_manager.go @@ -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