diff --git a/pkg/model/audit_event.go b/pkg/model/audit_event.go new file mode 100644 index 0000000..504cc33 --- /dev/null +++ b/pkg/model/audit_event.go @@ -0,0 +1,53 @@ +package model + +import ( + "encoding/json" + "time" +) + +type AuditEventType int32 + +// User clicked "Submit", "Accept" etc +const AuditEventTypeAction AuditEventType = 0 // Submit, Revoke, etc +type AuditEventDataAction struct { + TargetStatus uint32 +} + +// User wrote a comment +const AuditEventTypeComment AuditEventType = 1 // comment with comment id +type AuditEventDataComment struct { + Comment string +} + +// User changed Model +const AuditEventTypeChangeModel AuditEventType = 2 +type AuditEventDataChangeModel struct { + OldModelID uint64 + OldModelVersion uint64 + NewModelID uint64 + NewModelVersion uint64 +} +// Validator validates model +const AuditEventTypeChangeValidatedModel AuditEventType = 3 +type AuditEventDataChangeValidatedModel struct { + ValidatedModelID uint64 + ValidatedModelVerison uint64 +} + +// User changed DisplayName / Creator +const AuditEventTypeChangeDisplayName AuditEventType = 4 +const AuditEventTypeChangeCreator AuditEventType = 5 +type AuditEventDataChangeName struct { + OldName string + NewName string +} + +type AuditEvent struct { + ID int64 `gorm:"primaryKey"` + CreatedAt time.Time + User uint64 + ResourceType ResourceType // is this a submission or is it a mapfix + ResourceID int64 // submission / mapfix / map ID + EventType AuditEventType + EventData json.RawMessage `gorm:"type:jsonb"` +}