Files
new-api-custom/model/log_routing_group.go
T
cneicy ceddfd3d6b feat: sync deployed v1.0.0-rc.38-custom.42
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
2026-09-26 04:49:11 +08:00

35 lines
884 B
Go

package model
import "encoding/json"
// Correct historical error-log presentation from the already-stored routing
// evidence, without rewriting financial history or exposing private metadata.
// Consume records always retain their original billed group.
func normalizeErrorLogGroup(log *Log) {
if log == nil || log.Type != LogTypeError {
return
}
if log.ChannelId <= 0 {
log.Group = ""
return
}
var other struct {
Admin struct {
Events []struct {
ChannelID int `json:"channel_id"`
Group string `json:"group"`
} `json:"request_policy"`
} `json:"admin_info"`
}
if json.Unmarshal([]byte(log.Other), &other) != nil {
return
}
for i := len(other.Admin.Events) - 1; i >= 0; i-- {
event := other.Admin.Events[i]
if event.ChannelID == log.ChannelId && event.Group != "" && event.Group != "auto" {
log.Group = event.Group
return
}
}
}