// In file: internal/db/models.go package db import ( "time" "go.mongodb.org/mongo-driver/bson/primitive" ) // TrackedLink represents a file link in MongoDB. type TrackedLink struct { ID string `bson:"_id,omitempty"` // MongoDB uses _id MessageID int `bson:"message_id"` UserID int64 `bson:"user_id"` ShortHash string `bson:"short_hash"` FullHash string `bson:"full_hash"` LastRefreshedAt time.Time `bson:"last_refreshed_at"` CreatedAt time.Time `bson:"created_at"` } type User struct { ID primitive.ObjectID `bson:"_id,omitempty"` GoogleID string `bson:"google_id,unique"` // ID from the OAuth provider Email string `bson:"email,unique"` Name string `bson:"name"` AvatarURL string `bson:"avatar_url"` TelegramID int64 `bson:"telegram_id,omitempty"` // The linked Telegram User ID CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` } // OTPRequest stores a temporary one-time password for account linking. type OTPRequest struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID primitive.ObjectID `bson:"user_id"` // Links to the User._id OTPHash string `bson:"otp_hash"` ExpiresAt time.Time `bson:"expires_at"` CreatedAt time.Time `bson:"created_at"` } // UserRecord represents a user from the 'users' collection. // We only need the fields Go needs to interact with. type UserRecord struct { ID primitive.ObjectID `bson:"_id,omitempty"` TelegramID int64 `bson:"telegram_id"` } type FileRecord struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID primitive.ObjectID `bson:"userId"` FolderID *primitive.ObjectID `bson:"folderId,omitempty"` // Pointer to allow null MessageID int `bson:"messageId"` FileName string `bson:"fileName"` FileSize int64 `bson:"fileSize"` MimeType string `bson:"mimeType"` ShortHash string `bson:"shortHash"` FullHash string `bson:"fullHash"` CreatedAt time.Time `bson:"createdAt"` UpdatedAt time.Time `bson:"updatedAt"` } // UserStats represents user usage statistics type UserStats struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID int64 `bson:"user_id,unique"` FilesUploaded int64 `bson:"files_uploaded"` TotalSize int64 `bson:"total_size"` // in bytes TotalDownloads int64 `bson:"total_downloads"` BandwidthUsed int64 `bson:"bandwidth_used"` // in bytes LastActive time.Time `bson:"last_active"` CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` // Usage limits DailyLimit int64 `bson:"daily_limit"` // files per day MonthlyLimit int64 `bson:"monthly_limit"` // files per month Role string `bson:"role"` // "basic", "premium", "admin" } // DailyUsage tracks daily usage per user type DailyUsage struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID int64 `bson:"user_id"` Date string `bson:"date"` // YYYY-MM-DD format FilesCount int `bson:"files_count"` BandwidthUsed int64 `bson:"bandwidth_used"` CreatedAt time.Time `bson:"created_at"` } // UserSettings represents user preferences type UserSettings struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID int64 `bson:"user_id,unique"` DefaultExpiration int `bson:"default_expiration"` // hours, 0 = never EnableNotifications bool `bson:"enable_notifications"` Theme string `bson:"theme"` // "light", "dark" Language string `bson:"language"` AutoDelete bool `bson:"auto_delete"` // auto delete after expiration CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` } // FileHistory tracks user's file operations for history/search type FileHistory struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID int64 `bson:"user_id"` MessageID int `bson:"message_id"` FileName string `bson:"file_name"` FileSize int64 `bson:"file_size"` MimeType string `bson:"mime_type"` ShortHash string `bson:"short_hash"` FullHash string `bson:"full_hash"` DownloadCount int `bson:"download_count"` LastAccessed time.Time `bson:"last_accessed"` CreatedAt time.Time `bson:"created_at"` ExpiresAt *time.Time `bson:"expires_at,omitempty"` // optional expiration } // UserBot represents a user's personal bot configuration type UserBot struct { ID primitive.ObjectID `bson:"_id,omitempty"` UserID int64 `bson:"user_id,unique"` BotToken string `bson:"bot_token"` // Encrypted bot token BotUsername string `bson:"bot_username"` // Bot username for display BotID int64 `bson:"bot_id"` // Bot's Telegram ID IsActive bool `bson:"is_active"` // Whether bot is currently active IsVerified bool `bson:"is_verified"` // Whether bot token was validated LastUsed time.Time `bson:"last_used"` // Last time bot was used ErrorCount int `bson:"error_count"` // Track consecutive errors LastError string `bson:"last_error,omitempty"` // Last error message CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` } // UserRole constants const ( RoleBasic = "basic" RolePremium = "premium" RoleAdmin = "admin" ) // Default limits per role const ( BasicDailyLimit = 50 BasicMonthlyLimit = 1000 PremiumDailyLimit = 200 PremiumMonthlyLimit = 5000 AdminDailyLimit = -1 // unlimited AdminMonthlyLimit = -1 // unlimited )