package models

import (
	"time"

	"github.com/google/uuid"
)

type AuditLog struct {
	ID         uuid.UUID  `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
	ActorID    uuid.UUID  `gorm:"type:uuid;not null;index" json:"actor_id"`
	Action     string     `gorm:"type:varchar(64);not null;index" json:"action"`
	TargetType string     `gorm:"type:varchar(32)" json:"target_type"`
	TargetID   *uuid.UUID `gorm:"type:uuid" json:"target_id,omitempty"`
	Details    *string    `gorm:"type:text" json:"details,omitempty"`
	IPAddress  *string    `gorm:"type:varchar(45)" json:"ip_address,omitempty"`
	CreatedAt  time.Time  `gorm:"not null;index" json:"created_at"`

	Actor User `gorm:"foreignKey:ActorID" json:"actor,omitempty"`
}

const (
	AuditBanUser       = "ban_user"
	AuditUnbanUser     = "unban_user"
	AuditWarnUser      = "warn_user"
	AuditChangeRole    = "change_role"
	AuditChangeTier    = "change_tier"
	AuditEditEloConfig = "edit_elo_config"
	AuditOverrideMMR   = "override_mmr"
	AuditUnlinkSteam   = "unlink_steam"
	AuditCancelMatch   = "cancel_match"
	AuditNullifyMatch  = "nullify_match"
	AuditEditConfig    = "edit_config"
	AuditAddNote       = "add_note"
	AuditTicketAction  = "ticket_action"
	AuditEditUser      = "edit_user"
	AuditMaintenance   = "maintenance"
	AuditSeed          = "seed"
)
