This commit is contained in:
Quaternions 2025-04-09 15:09:46 -07:00
parent 1f1deacc2d
commit ccf1ff6866
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
8 changed files with 29 additions and 24 deletions

@ -5,7 +5,7 @@ import (
"time" "time"
) )
type AuditEventType int32 type AuditEventType uint32
// User clicked "Submit", "Accept" etc // User clicked "Submit", "Accept" etc
const AuditEventTypeAction AuditEventType = 0 const AuditEventTypeAction AuditEventType = 0
@ -43,11 +43,11 @@ type AuditEventDataChangeName struct {
} }
type AuditEvent struct { type AuditEvent struct {
ID int64 `gorm:"primaryKey"` ID uint64 `gorm:"primaryKey"`
CreatedAt time.Time CreatedAt time.Time
User uint64 User uint64
ResourceType ResourceType // is this a submission or is it a mapfix ResourceType ResourceType // is this a submission or is it a mapfix
ResourceID int64 // submission / mapfix / map ID ResourceID uint64 // submission / mapfix / map ID
EventType AuditEventType EventType AuditEventType
EventData json.RawMessage `gorm:"type:jsonb"` EventData json.RawMessage `gorm:"type:jsonb"`
} }

@ -2,7 +2,7 @@ package model
import "time" import "time"
type MapfixStatus int32 type MapfixStatus uint32
const ( const (
// Phase: Creation // Phase: Creation
@ -25,7 +25,7 @@ const (
) )
type Mapfix struct { type Mapfix struct {
ID int64 `gorm:"primaryKey"` ID uint64 `gorm:"primaryKey"`
DisplayName string DisplayName string
Creator string Creator string
GameID uint32 GameID uint32

@ -7,26 +7,26 @@ package model
type CreateSubmissionRequest struct { type CreateSubmissionRequest struct {
// operation_id is passed back in the response message // operation_id is passed back in the response message
OperationID int32 OperationID uint32
ModelID uint64 ModelID uint64
} }
type CreateMapfixRequest struct { type CreateMapfixRequest struct {
OperationID int32 OperationID uint32
ModelID uint64 ModelID uint64
TargetAssetID uint64 TargetAssetID uint64
} }
type ValidateSubmissionRequest struct { type ValidateSubmissionRequest struct {
// submission_id is passed back in the response message // submission_id is passed back in the response message
SubmissionID int64 SubmissionID uint64
ModelID uint64 ModelID uint64
ModelVersion uint64 ModelVersion uint64
ValidatedModelID *uint64 // optional value ValidatedModelID *uint64 // optional value
} }
type ValidateMapfixRequest struct { type ValidateMapfixRequest struct {
MapfixID int64 MapfixID uint64
ModelID uint64 ModelID uint64
ModelVersion uint64 ModelVersion uint64
ValidatedModelID *uint64 // optional value ValidatedModelID *uint64 // optional value
@ -34,14 +34,14 @@ type ValidateMapfixRequest struct {
// Create a new map // Create a new map
type UploadSubmissionRequest struct { type UploadSubmissionRequest struct {
SubmissionID int64 SubmissionID uint64
ModelID uint64 ModelID uint64
ModelVersion uint64 ModelVersion uint64
ModelName string ModelName string
} }
type UploadMapfixRequest struct { type UploadMapfixRequest struct {
MapfixID int64 MapfixID uint64
ModelID uint64 ModelID uint64
ModelVersion uint64 ModelVersion uint64
TargetAssetID uint64 TargetAssetID uint64

@ -2,7 +2,7 @@ package model
import "time" import "time"
type OperationStatus int32 type OperationStatus uint32
const ( const (
OperationStatusCreated OperationStatus = 0 OperationStatusCreated OperationStatus = 0
OperationStatusCompleted OperationStatus = 1 OperationStatusCompleted OperationStatus = 1
@ -10,7 +10,7 @@ const (
) )
type Operation struct { type Operation struct {
ID int32 `gorm:"primaryKey"` ID uint32 `gorm:"primaryKey"`
CreatedAt time.Time CreatedAt time.Time
Owner uint64 // UserID Owner uint64 // UserID
StatusID OperationStatus StatusID OperationStatus

@ -1,6 +1,6 @@
package model package model
type Page struct { type Page struct {
Number int32 Number uint32
Size int32 Size uint32
} }

@ -2,7 +2,7 @@ package model
import "time" import "time"
type Policy int32 type Policy uint32
const ( const (
ScriptPolicyNone Policy = 0 // not yet reviewed ScriptPolicyNone Policy = 0 // not yet reviewed
@ -13,7 +13,7 @@ const (
) )
type ScriptPolicy struct { type ScriptPolicy struct {
ID int64 `gorm:"primaryKey"` ID uint64 `gorm:"primaryKey"`
// Hash of the source code that leads to this policy. // Hash of the source code that leads to this policy.
// If this is a replacement mapping, the original source may not be pointed to by any policy. // If this is a replacement mapping, the original source may not be pointed to by any policy.
// The original source should still exist in the scripts table, which can be located by the same hash. // The original source should still exist in the scripts table, which can be located by the same hash.
@ -21,7 +21,7 @@ type ScriptPolicy struct {
// The ID of the replacement source (ScriptPolicyReplace) // The ID of the replacement source (ScriptPolicyReplace)
// or verbatim source (ScriptPolicyAllowed) // or verbatim source (ScriptPolicyAllowed)
// or 0 (other) // or 0 (other)
ToScriptID int64 ToScriptID uint64
Policy Policy Policy Policy
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time

@ -23,7 +23,7 @@ func HashParse(hash string) (uint64, error){
return strconv.ParseUint(hash, 16, 64) return strconv.ParseUint(hash, 16, 64)
} }
type ResourceType int32 type ResourceType uint32
const ( const (
ResourceUnknown ResourceType = 0 ResourceUnknown ResourceType = 0
ResourceMapfix ResourceType = 1 ResourceMapfix ResourceType = 1
@ -31,12 +31,17 @@ const (
) )
type Script struct { type Script struct {
ID int64 `gorm:"primaryKey"` ID uint64 `gorm:"primaryKey"`
Name string Name string
Hash int64 // postgres does not support unsigned integers, so we have to pretend hash uint64
Source string Source string
ResourceType ResourceType // is this a submission or is it a mapfix ResourceType ResourceType // is this a submission or is it a mapfix
ResourceID int64 // which submission / mapfix did this script first appear in ResourceID uint64 // which submission / mapfix did this script first appear in
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time UpdatedAt time.Time
} }
// postgres does not support unsigned integers, so we have to pretend
func (script *Script) GetPostgresInt64() (int64) {
return int64(script.hash)
}

@ -2,7 +2,7 @@ package model
import "time" import "time"
type SubmissionStatus int32 type SubmissionStatus uint32
const ( const (
// Phase: Creation // Phase: Creation
@ -26,7 +26,7 @@ const (
) )
type Submission struct { type Submission struct {
ID int64 `gorm:"primaryKey"` ID uint64 `gorm:"primaryKey"`
DisplayName string DisplayName string
Creator string Creator string
GameID uint32 GameID uint32