Merge branch 'main' into security/csrf-ssrf-ratelimit
All checks were successful
check / check (push) Successful in 1m59s
All checks were successful
check / check (push) Successful in 1m59s
This commit is contained in:
@@ -520,14 +520,14 @@ func (h *Handlers) HandleTargetCreate() http.HandlerFunc {
|
||||
|
||||
// Validate target type
|
||||
switch targetType {
|
||||
case database.TargetTypeHTTP, database.TargetTypeDatabase, database.TargetTypeLog:
|
||||
case database.TargetTypeHTTP, database.TargetTypeDatabase, database.TargetTypeLog, database.TargetTypeSlack:
|
||||
// valid
|
||||
default:
|
||||
http.Error(w, "Invalid target type", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// Build config JSON for HTTP targets
|
||||
// Build config JSON based on target type
|
||||
var configJSON string
|
||||
if targetType == database.TargetTypeHTTP {
|
||||
if url == "" {
|
||||
@@ -554,6 +554,20 @@ func (h *Handlers) HandleTargetCreate() http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
configJSON = string(configBytes)
|
||||
} else if targetType == database.TargetTypeSlack {
|
||||
if url == "" {
|
||||
http.Error(w, "Webhook URL is required for Slack targets", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
cfg := map[string]interface{}{
|
||||
"webhook_url": url,
|
||||
}
|
||||
configBytes, err := json.Marshal(cfg)
|
||||
if err != nil {
|
||||
http.Error(w, "Internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
configJSON = string(configBytes)
|
||||
}
|
||||
|
||||
maxRetries := 0 // default: fire-and-forget (no retries)
|
||||
|
||||
Reference in New Issue
Block a user