diff --git a/audit/audit.go b/audit/audit.go index 6d2968832be7f6b62b5a4f83b7e984bc59f66234..70666b3fb8ef8be6eee8e0e4d56bcee816a26616 100644 --- a/audit/audit.go +++ b/audit/audit.go @@ -26,13 +26,13 @@ type FieldChange struct { To interface{} `json:"change_to"` } -func GetAuditEvent(original interface{}, new interface{}, username *string) (Event, error) { +func GetChanges(original interface{}, new interface{}) (map[string]interface{}, error) { + changes := map[string]interface{}{} changelog, err := diff.Diff(original, new) if err != nil { - return Event{}, err + return changes, err } - changes := map[string]interface{}{} for _, change := range changelog { if len(change.Path) == 1 { @@ -119,38 +119,7 @@ func GetAuditEvent(original interface{}, new interface{}, username *string) (Eve } } - objectID := getIntValue(original, "ID") - - if objectID == 0 { - objectID = getIntValue(new, "ID") - } - - objectIDString := string_utils.Int64ToString(objectID) - - if objectIDString == "0" { - objectIDString = getStringValue(original, "Username") - } - - if objectIDString == "" { - objectIDString = getStringValue(new, "Username") - } - - providerID := getIntValue(original, "ProviderID") - if providerID == 0 { - providerID = getIntValue(new, "ProviderID") - } - - auditEvent := Event{ - ObjectID: objectIDString, - ProviderID: providerID, - Source: "SYSTEM", - Timestamp: time.Now(), - Change: changes, - } - if username != nil { - auditEvent.Source = *username - } - return auditEvent, nil + return changes, nil } var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")