Documentation
¶
Index ¶
- Constants
- Variables
- type Achievement
- type DBCache
- type Developer
- type DeveloperEvent
- type DeveloperGame
- type DeveloperGameReport
- type DeveloperMember
- type DeveloperReport
- type Event
- type FeatureTag
- type GameComment
- type Guest
- type GuestSession
- type Image
- type RecoveryCode
- type ReportTag
- type SystemEvent
- type TokenBody
- type User
- type UserDiscord
- type UserEvent
- type UserGameSave
- type UserGitHub
- type UserGoogle
- type UserReport
- type UserSession
- type UserTOTP
- type Verification
Constants ¶
Variables ¶
var DeveloperEvents map[string][]any = map[string][]any{ "developer_created": {"Developer account was created", LogInfo}, "developer_deleted": {"Developer account was deleted", LogInfo}, "developer_owner_change": {"Owner of developer account was changed", LogInfo}, "developer_approval_start": {"Developer account approval was started", LogInfo}, "developer_approval_success": {"Developer account was approved", LogInfo}, "developer_approval_deny": {"Developer account was denied", LogInfo}, "developer_approval_failure": {"Developer account approval failed", LogError}, }
Define the events used for logging developer activity
var GameFeatureTags = map[string]string{
"achievements": "This game supports earning achievements.",
"config": "This game can make changes to your account.",
"controllers": "This game supports controllers.",
"dlc": "This game supports Downloadable Content.",
"legacy": "This game supports legacy CloudLink clients.",
"matchmaking": "This game supports matchmaking.",
"save": "This game supports cloud save data.",
"points": "This game can earn, spend, trade or redeem points.",
"everyone": "This game is suitable for everyone.",
"mature": "This game is only for adult audiences.",
"older": "This game is only for teens and older audiences.",
"mobile": "This game is only available on mobile devices.",
"multidev": "This game can be played on mobile or desktop devices.",
"oss": "The game is open source.",
"proprietary": "The source code of this game is proprietary.",
"ontw": "This game was made using Turbowarp.",
"onpm": "This game was made using PenguinMod.",
"oneq": "This game was made using E羊icques (SheepTester's Mod).",
"onscratch": "This game is also available on Scratch.",
"violent": "This game contains or references violent content.",
"substances": "This game contains or references drugs, alcohol or weapons.",
"review": "This game is undergoing review or awaiting approval by an administrator.",
"call": "This game supports voice chat.",
"mail": "This game can send and receive messages using your account.",
"vchat": "This game supports proximity voice chat.",
"vmail": "This game supports sending or receiving voicemail.",
}
var ReportTags = map[string][]any{ "tos": {"Violates the terms of service.", true, true, true}, "slander": {"Slanderous or false information.", true, true, true}, "spam": {"Contains spam.", true, true, true}, "ip": {"Violates my/someone's intellectual property rights.", true, true, true}, "missing": {"The project file is missing or damaged.", false, false, true}, "nsfw": {"Contains NSFW content and is not correctly tagged.", false, false, true}, "violent": {"Contains violent content and is not correctly tagged.", false, false, true}, "substances": {"Contains or refers to substances and is not correctly tagged.", false, false, true}, "bullying": {"Bullying or harassment.", true, true, false}, }
{key} => {description, isUser, isDeveloper, isGame}
var SystemEvents map[string][]any = map[string][]any{ "secret_gen_error": {"Failed to generate user secret", LogError}, "hash_gen_error": {"Failed to generate user password hash", LogError}, "get_user_error": {"Failed to get user", LogError}, "email_off": {"Email services are nonfunctional", LogWarn}, "totp_error": {"TOTP validator failure", LogError}, "create_user_error": {"Failed to create user", LogError}, }
var UserEvents map[string][]any = map[string][]any{ "user_created": {"User was successfully created", LogInfo}, "user_deleted": {"User was successfully deleted", LogInfo}, "user_error": {"User error", LogError}, "user_login": {"User was successfully logged in", LogInfo}, "user_logout": {"User was successfully logged out", LogInfo}, "user_session_created": {"User session was successfully created", LogInfo}, "user_session_deleted": {"User session was successfully deleted", LogInfo}, "user_session_error": {"User session error", LogError}, "developer_member_created": {"Developer member was successfully created", LogInfo}, "developer_member_deleted": {"Developer member was successfully deleted", LogInfo}, "game_save_created": {"Game save was successfully created", LogInfo}, "game_save_deleted": {"Game save was successfully deleted", LogInfo}, "game_save_error": {"Game save error", LogError}, "user_auth_password_error": {"Password authentication error", LogError}, "user_totp_enroll_started": {"User started TOTP enrollment", LogInfo}, "user_totp_enroll_success": {"User successfully enrolled TOTP", LogInfo}, "user_totp_enroll_failure": {"User failed to enroll TOTP", LogError}, "user_auth_totp_error": {"TOTP authentication error", LogError}, "user_verify_sent": {"User verification code was sent", LogInfo}, "user_verify_set_failure": {"Failed to set verification code", LogError}, "user_verify_bypassed_test": {"User verification was bypassed; testing mode enabled", LogWarn}, "user_verify_bypassed_disabled": {"User verification was bypassed; email verification is disabled", LogWarn}, "user_verify_success": {"User successfully verified", LogInfo}, "user_verify_failure": {"User failed to verify", LogError}, "user_recovery_set": {"Recovery codes were generated", LogInfo}, "user_recovery_set_failure": {"Recovery code setup error", LogError}, "user_recovery_success": {"User used recovery code", LogInfo}, "user_recovery_failure": {"Error using recovery code", LogError}, "user_password_reset_sent": {"User password reset code was sent", LogInfo}, "user_password_reset_verified": {"User password reset code was verified", LogInfo}, "user_password_reset_success": {"User successfully reset password", LogInfo}, "user_password_reset_failure": {"Error while resetting password", LogError}, "recovery_code_retrieval_error": {"Failed to retrieve user recovery codes", LogError}, "recovery_code_store_error": {"Failed to store user recovery codes", LogError}, "guest_created": {"Guest account was created", LogInfo}, "guest_create_error": {"Failed to create guest account", LogError}, }
Define the events used for logging user activity
Functions ¶
This section is empty.
Types ¶
type Achievement ¶
type Achievement struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
UserID string `gorm:"not null"`
DeveloperGameID string `gorm:"not null"`
Description string `gorm:"type:tinytext;not null"`
Points uint64 `gorm:"not null;default:0"`
IconID *string
CreatedAt time.Time
User *User `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
DeveloperGame *DeveloperGame `gorm:"foreignKey:DeveloperGameID;references:ID;constraint:OnDelete:CASCADE;"`
Icon *Image `gorm:"foreignKey:IconID;references:ID;constraint:OnDelete:SET NULL;"`
}
type DBCache ¶
type DBCache struct {
// contains filtered or unexported fields
}
DBCache is a basic key-value in-memory cache for the database.
func NewDBCache ¶
func NewDBCache() *DBCache
type Developer ¶
type Developer struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
Name string `gorm:"type:tinytext;not null;default:''"`
Description string `gorm:"type:mediumtext"`
State bitfield.Bitfield8 `gorm:"not null;default:0;"`
BannerID *string
AvatarID *string
CreatedAt time.Time
UpdatedAt time.Time
Banner *Image `gorm:"foreignKey:BannerID;references:ID;constraint:OnDelete:SET NULL;"`
Avatar *Image `gorm:"foreignKey:AvatarID;references:ID;constraint:OnDelete:SET NULL;"`
DeveloperMembers []*DeveloperMember `gorm:"foreignKey:DeveloperID"`
}
Developer represents a game developer.
type DeveloperEvent ¶
type DeveloperEvent struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
DeveloperID string
EventID string
Details string `gorm:"type:tinytext"`
Successful bool
CreatedAt time.Time
Developer *Developer `gorm:"foreignKey:DeveloperID;references:ID;constraint:OnDelete:CASCADE;"`
Event *Event `gorm:"foreignKey:EventID;references:ID;constraint:OnDelete:CASCADE;"`
}
DeveloperEvent is used to log changes to a developer profile, ranging from memberships to approvals.
type DeveloperGame ¶
type DeveloperGame struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
Name string `gorm:"type:tinytext;not null;default:''"`
Description string `gorm:"type:mediumtext"`
DeveloperID string
State bitfield.Bitfield8 `gorm:"not null;default:0;"`
ThumbnailID *string
CreatedAt time.Time
Thumbnail *Image `gorm:"foreignKey:ThumbnailID;references:ID;constraint:OnDelete:SET NULL;"`
Developer *Developer `gorm:"foreignKey:DeveloperID;references:ID;constraint:OnDelete:CASCADE;"`
Features []*FeatureTag `gorm:"many2many:developer_game_features;"`
UserGameSaves []*UserGameSave `gorm:"foreignKey:DeveloperGameID"`
GameComments []*GameComment `gorm:"foreignKey:DeveloperGameID"`
}
DeveloperGame represents a game created by a developer.
type DeveloperGameReport ¶
type DeveloperGameReport struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
SubmittedUserID string `gorm:"not null"`
DeveloperGameID string `gorm:"not null"`
ReportTagID *string
Details string `gorm:"type:mediumtext"`
CreatedAt time.Time
SubmittedUser *User `gorm:"foreignKey:SubmittedUserID;references:ID;constraint:OnDelete:CASCADE;"`
DeveloperGame *DeveloperGame `gorm:"foreignKey:DeveloperGameID;references:ID;constraint:OnDelete:CASCADE;"`
ReportTag *ReportTag `gorm:"foreignKey:ReportTagID;references:ID;constraint:OnDelete:CASCADE;"`
}
DeveloperGameReport represents a user-submitted report on a developer's game. By specifying a ReportTag, the user can specify the kind of the report. If the ReportTag is null, the user can fill out the ReportDetails field for a custom report.
type DeveloperMember ¶
type DeveloperMember struct {
UserID string `gorm:"not null"`
DeveloperID string `gorm:"not null"`
State bitfield.Bitfield8 `gorm:"not null;default:0;"`
User *User `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
Developer *Developer `gorm:"foreignKey:DeveloperID;references:ID;constraint:OnDelete:CASCADE;"`
}
DeveloperMember represents memberships between a user and a developer account.
type DeveloperReport ¶
type DeveloperReport struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
SubmittedUserID string `gorm:"not null"`
DeveloperID string `gorm:"not null"`
ReportTagID *string
Details string `gorm:"type:mediumtext"`
CreatedAt time.Time
SubmittedUser *User `gorm:"foreignKey:SubmittedUserID;references:ID;constraint:OnDelete:CASCADE;"`
Developer *Developer `gorm:"foreignKey:DeveloperID;references:ID;constraint:OnDelete:CASCADE;"`
ReportTag *ReportTag `gorm:"foreignKey:ReportTagID;references:ID;constraint:OnDelete:CASCADE;"`
}
DeveloperReport represents a user-submitted report on a developer's profile. By specifying a ReportTag, the user can specify the kind of the report. If the ReportTag is null, the user can fill out the ReportDetails field for a custom report.
type Event ¶
type Event struct {
ID string `gorm:"primaryKey;type:varchar(50);unique;not null"`
Description string `gorm:"type:tinytext"`
LogLevel uint8
}
Event is a generic entity used to de-duplicate events across the system.
type FeatureTag ¶
type FeatureTag struct {
ID string `gorm:"primaryKey;type:varchar(50);unique;not null;"`
Description string `gorm:"type:tinytext"`
}
FeatureTag is a generic entity used to de-duplicate features for games.
type GameComment ¶
type GameComment struct {
ID string `gorm:"primaryKey;type:char(26);not null"`
UserID string `gorm:"type:char(26);not null"`
DeveloperGameID string `gorm:"type:char(26);not null"`
ParentID *string
Content string `gorm:"type:mediumtext;not null"`
CreatedAt time.Time
UpdatedAt time.Time
// Relationships
User *User `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
DeveloperGame *DeveloperGame `gorm:"foreignKey:DeveloperGameID;references:ID;constraint:OnDelete:CASCADE;"`
Parent *GameComment `gorm:"foreignKey:ParentID;references:ID;constraint:OnDelete:CASCADE;"`
Replies []*GameComment `gorm:"foreignKey:ParentID"`
}
GameComment represents a comment on a game by a user.
type GuestSession ¶
type GuestSession struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
UserID string `gorm:"not null"`
UserAgent string `gorm:"mediumtext;not null"`
Origin string `gorm:"mediumtext;not null"`
IP string `gorm:"mediumtext;not null"`
CreatedAt time.Time
UpdatedAt time.Time
ExpiresAt time.Time
Guest *Guest `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
}
type Image ¶
type Image struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
Link string `gorm:"type:mediumtext;not null"`
CreatedAt time.Time
UpdatedAt time.Time
}
Image represents an image stored on the server's hosted folder.
type RecoveryCode ¶
type ReportTag ¶
type ReportTag struct {
ID string `gorm:"primaryKey;type:varchar(50);unique;not null;"`
Description string `gorm:"type:tinytext"`
IsUser bool
IsDeveloper bool
IsGame bool
}
ReportTag is a generic entity used to de-duplicate report types.
type SystemEvent ¶
type User ¶
type User struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
Username string `gorm:"unique;not null;min:1;max:20"`
Email string `gorm:"unique;not null;min:1;max:255"`
Password string `gorm:"type:mediumtext"`
Secret string `gorm:"type:mediumtext"`
State bitfield.Bitfield8 `gorm:"not null;default:0;"`
AvatarID *string
BannerID *string
CreatedAt time.Time
UpdatedAt time.Time
Avatar *Image `gorm:"foreignKey:AvatarID;references:ID;constraint:OnDelete:SET NULL;"`
Banner *Image `gorm:"foreignKey:BannerID;references:ID;constraint:OnDelete:SET NULL;"`
UserGameSaves []*UserGameSave `gorm:"foreignKey:UserID"`
DeveloperMember []*DeveloperMember `gorm:"foreignKey:UserID"`
GameComments []*GameComment `gorm:"foreignKey:UserID"`
}
type UserDiscord ¶
type UserEvent ¶
type UserEvent struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
UserID string `gorm:"not null"`
EventID string
Details string `gorm:"type:tinytext"`
Successful bool
CreatedAt time.Time
User *User `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
Event *Event `gorm:"foreignKey:EventID;references:ID;constraint:OnDelete:CASCADE;"`
}
UserEvent is used to log changes to a user account, ranging from authentication and account changes to account errors.
type UserGameSave ¶
type UserGameSave struct {
UserID string `gorm:"primaryKey;type:char(26);not null"`
DeveloperGameID string `gorm:"primaryKey;type:char(26);not null"`
SaveSlot uint8 `gorm:"not null;min:1;max:10"`
SaveData string `gorm:"type:mediumtext"`
CreatedAt time.Time
UpdatedAt time.Time
User *User `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
DeveloperGame *DeveloperGame `gorm:"foreignKey:DeveloperGameID;references:ID;constraint:OnDelete:CASCADE;"`
}
UserGameSave is used to store a user's game save data.
type UserGitHub ¶
type UserGoogle ¶
type UserReport ¶
type UserReport struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
UserID string `gorm:"type:char(26);not null"`
SubmittedUserID string `gorm:"type:char(26);not null"`
ReportTagID *string
Details string `gorm:"type:mediumtext"`
CreatedAt time.Time
SubmittedUser *User `gorm:"foreignKey:SubmittedUserID;references:ID;constraint:OnDelete:CASCADE;"`
User *User `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
ReportTag *ReportTag `gorm:"foreignKey:ReportTagID;references:ID;constraint:OnDelete:CASCADE;"`
}
UserReport represents a user-submitted report on another user. By specifying a ReportTag, the user can specify the kind of the report. If the ReportTag is null, the user can fill out the ReportDetails field for a custom report.
type UserSession ¶
type UserSession struct {
ID string `gorm:"primaryKey;type:char(26);unique;not null"`
UserID string `gorm:"not null"`
UserAgent string `gorm:"mediumtext;not null"`
Origin string `gorm:"mediumtext;not null"`
IP string `gorm:"mediumtext;not null"`
CreatedAt time.Time
UpdatedAt time.Time
ExpiresAt time.Time
User *User `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE;"`
}