package model import "time" // User represents a system user with role-based access control. type User struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` Username string `gorm:"uniqueIndex;size:50;not null" json:"username"` Password string `gorm:"size:255;not null" json:"-"` // bcrypt hash, never exposed in JSON Nickname string `gorm:"size:100" json:"nickname"` Role string `gorm:"size:20;not null;default:'viewer'" json:"role"` // admin / operator / viewer Enabled bool `gorm:"default:true" json:"enabled"` MustChangePassword bool `gorm:"default:false" json:"must_change_password"` LastLoginAt *time.Time `json:"last_login_at"` LastLoginIP string `gorm:"size:45" json:"last_login_ip"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // TgAccount represents a Telegram account managed via the admin panel. type TgAccount struct { ID uint `gorm:"primaryKey;autoIncrement" json:"id"` Phone string `gorm:"uniqueIndex;size:50;not null" json:"phone"` SessionFile string `gorm:"size:500;not null" json:"session_file"` AppID int `gorm:"not null" json:"app_id"` AppHash string `gorm:"size:100;not null" json:"app_hash"` Remark string `gorm:"size:255" json:"remark"` Enabled bool `gorm:"default:true" json:"enabled"` Status string `gorm:"size:20;default:'idle'" json:"status"` // idle / online / cooling // Protocol-number import additions (all nullable to keep legacy rows valid). TwoFAEnc []byte `gorm:"type:varbinary(255)" json:"-"` // AES-GCM ciphertext; never emitted in JSON Device string `gorm:"size:100" json:"device"` // e.g. "Xiaomi Mix 4" AppVersion string `gorm:"size:50" json:"app_version"` // e.g. "12.0.0 (6163)" SDK string `gorm:"size:100" json:"sdk"` // e.g. "Android 13 (33)" LangPack string `gorm:"size:50" json:"lang_pack"` // e.g. "android" LangCode string `gorm:"size:20" json:"lang_code"` // e.g. "en" SystemLangCode string `gorm:"size:20" json:"system_lang_code"` // e.g. "en-US" FirstName string `gorm:"size:100" json:"first_name"` LastName string `gorm:"size:100" json:"last_name"` TgUsername string `gorm:"size:100;column:tg_username" json:"tg_username"` OriginDir string `gorm:"size:500" json:"origin_dir"` // sessions/.origin/ absolute path ImportStatus string `gorm:"size:20" json:"import_status"` // ok / session_invalid / dead Source string `gorm:"size:20" json:"source"` // protocol / manual CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }