This commit is contained in:
@@ -58,6 +58,8 @@ func normalizeCardAuditPayload(beforeData, afterData map[string]any) (map[string
|
||||
}
|
||||
beforeContent := stripCardOperationMeta(beforeData)
|
||||
afterContent := stripCardOperationMeta(afterData)
|
||||
beforeContent = ensureCardOperationContentMap(beforeContent, beforeData)
|
||||
afterContent = ensureCardOperationContentMap(afterContent, afterData)
|
||||
enrichCardOperationContent(beforeContent, beforeData)
|
||||
enrichCardOperationContent(afterContent, afterData)
|
||||
return assetAuditSvc.WrapOperationContent(beforeContent, afterContent, snapshot)
|
||||
@@ -80,6 +82,24 @@ func stripCardOperationMeta(data map[string]any) map[string]any {
|
||||
return out
|
||||
}
|
||||
|
||||
func ensureCardOperationContentMap(content map[string]any, raw map[string]any) map[string]any {
|
||||
if content != nil || len(raw) == 0 {
|
||||
return content
|
||||
}
|
||||
if _, ok := raw["card"].(map[string]any); ok {
|
||||
return make(map[string]any)
|
||||
}
|
||||
if _, ok := raw["device"].(map[string]any); ok {
|
||||
return make(map[string]any)
|
||||
}
|
||||
switch raw["cards"].(type) {
|
||||
case []map[string]any, []any:
|
||||
return make(map[string]any)
|
||||
default:
|
||||
return content
|
||||
}
|
||||
}
|
||||
|
||||
func enrichCardOperationContent(content map[string]any, raw map[string]any) {
|
||||
if len(raw) == 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user