submissions: audit model

This commit is contained in:
Quaternions 2025-04-07 12:54:12 -07:00
parent 24a5baae77
commit 70119a0b3c
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131

53
pkg/model/audit_event.go Normal file

@ -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"`
}