package database

import "database/sql"

// User mirrors the `users` table. A user is created on first /start.
type User struct {
	ID           int64
	TgID         int64
	Username     string
	FirstName    string
	LastName     string
	Language     string
	IsBanned     bool
	IsAdmin      bool
	CreatedCount int
	CreatedAt    string
	LastSeen     sql.NullString
}

// APIKey is one api_id/api_hash pair produced via my.telegram.org.
type APIKey struct {
	ID           int64
	UserID       int64
	TgID         int64
	Phone        string
	AppTitle     string
	AppShortname string
	AppPlatform  string
	APIID        string
	APIHash      string
	Status       string // active | revoked
	CreatedAt    string
}

// Proxy is a configured HTTP/SOCKS proxy used for my.telegram.org requests.
type Proxy struct {
	ID         int64
	Kind       string // http | socks5
	Host       string
	Port       int
	Username   string
	Password   string
	Enabled    bool
	LastUsed   sql.NullString
	FailCount  int
	CreatedAt  string
}

// LogEntry is one row in the audit / application log shown in the web panel.
type LogEntry struct {
	ID        int64
	Level     string
	Source    string
	UserID    sql.NullInt64
	Message   string
	CreatedAt string
}

// Setting is a simple key/value pair stored in the `settings` table, used for
// things like the bcrypt-hashed web admin password and runtime toggles.
type Setting struct {
	Key   string
	Value string
}
