mirror of
https://github.com/Dvorinka/Trackeep.git
synced 2026-06-03 20:12:58 +00:00
feat: major feature updates and cleanup
- Add Redis architecture implementation - Update browser extension functionality - Clean up deprecated files and documentation - Enhance backend handlers for auth, messages, search - Add new configuration options and settings - Update Docker and deployment configurations
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// APIKey represents an API key for browser extension
|
||||
type APIKey struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name" gorm:"not null"`
|
||||
Key string `json:"key" gorm:"not null;uniqueIndex"`
|
||||
UserID uint `json:"user_id" gorm:"not null"`
|
||||
Permissions []string `json:"permissions" gorm:"serializer:json"`
|
||||
IsActive bool `json:"is_active" gorm:"default:true"`
|
||||
LastUsed *time.Time `json:"last_used,omitempty" gorm:"not null"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
ExpiresAt *time.Time `json:"expires_at,omitempty" gorm:"not null"`
|
||||
User User `json:"user,omitempty" gorm:"foreignKey:UserID"`
|
||||
}
|
||||
|
||||
// BrowserExtension represents a browser extension registration
|
||||
type BrowserExtension struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
UserID uint `json:"user_id" gorm:"not null"`
|
||||
ExtensionID string `json:"extension_id" gorm:"not null"`
|
||||
Name string `json:"name" gorm:"not null"`
|
||||
IsActive bool `json:"is_active" gorm:"default:true"`
|
||||
LastSeen *time.Time `json:"last_seen,omitempty" gorm:"not null"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
User User `json:"user,omitempty" gorm:"foreignKey:UserID"`
|
||||
}
|
||||
@@ -49,6 +49,8 @@ func AutoMigrate() {
|
||||
&AISummary{},
|
||||
&AITaskSuggestion{},
|
||||
&UserAISettings{},
|
||||
&UserSearchSettings{},
|
||||
&UserUpdateSettings{},
|
||||
&AITagSuggestion{},
|
||||
&AIContentGeneration{},
|
||||
&AICodeReview{},
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// UserSearchSettings stores user-specific search API configurations
|
||||
type UserSearchSettings struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
|
||||
UserID uint `json:"user_id" gorm:"not null;uniqueIndex"`
|
||||
User User `json:"user,omitempty" gorm:"foreignKey:UserID"`
|
||||
|
||||
// Brave Search Settings
|
||||
BraveAPIKey string `json:"-" gorm:"column:brave_api_key"` // Encrypted
|
||||
BraveSearchBaseURL string `json:"brave_search_base_url" gorm:"default:https://api.search.brave.com/res/v1/web/search"`
|
||||
|
||||
// Serper (Google) Search Settings
|
||||
SerperAPIKey string `json:"-" gorm:"column:serper_api_key"` // Encrypted
|
||||
SerperBaseURL string `json:"serper_base_url" gorm:"default:https://google.serper.dev/search"`
|
||||
|
||||
// Search Configuration
|
||||
SearchAPIProvider string `json:"search_api_provider" gorm:"default:brave"` // brave, serper
|
||||
SearchResultsLimit int `json:"search_results_limit" gorm:"default:10"`
|
||||
SearchCacheTTL int `json:"search_cache_ttl" gorm:"default:300"` // seconds
|
||||
SearchRateLimit int `json:"search_rate_limit" gorm:"default:100"` // requests per minute
|
||||
}
|
||||
|
||||
// GetUserSearchSettings retrieves search settings for a user
|
||||
func GetUserSearchSettings(userID uint) (*UserSearchSettings, error) {
|
||||
var settings UserSearchSettings
|
||||
err := DB.Where("user_id = ?", userID).First(&settings).Error
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
// Create default settings
|
||||
settings = UserSearchSettings{
|
||||
UserID: userID,
|
||||
BraveSearchBaseURL: "https://api.search.brave.com/res/v1/web/search",
|
||||
SerperBaseURL: "https://google.serper.dev/search",
|
||||
SearchAPIProvider: "brave",
|
||||
SearchResultsLimit: 10,
|
||||
SearchCacheTTL: 300,
|
||||
SearchRateLimit: 100,
|
||||
}
|
||||
// Save defaults
|
||||
if err := DB.Create(&settings).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &settings, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &settings, nil
|
||||
}
|
||||
|
||||
// SaveUserSearchSettings saves search settings for a user
|
||||
func SaveUserSearchSettings(userID uint, settings *UserSearchSettings) error {
|
||||
settings.UserID = userID
|
||||
return DB.Where("user_id = ?", userID).Assign(settings).FirstOrCreate(settings).Error
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// UserUpdateSettings stores user-specific update and OAuth configurations
|
||||
type UserUpdateSettings struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
|
||||
UserID uint `json:"user_id" gorm:"not null;uniqueIndex"`
|
||||
User User `json:"user,omitempty" gorm:"foreignKey:UserID"`
|
||||
|
||||
// OAuth Service Configuration
|
||||
OAuthServiceURL string `json:"oauth_service_url" gorm:"default:https://oauth.trackeep.org"`
|
||||
|
||||
// Update Configuration
|
||||
AutoUpdateCheck bool `json:"auto_update_check" gorm:"default:false"`
|
||||
UpdateCheckInterval string `json:"update_check_interval" gorm:"default:24h"` // 1h, 6h, 12h, 24h, 168h
|
||||
PrereleaseUpdates bool `json:"prerelease_updates" gorm:"default:false"`
|
||||
}
|
||||
|
||||
// GetUserUpdateSettings retrieves update settings for a user
|
||||
func GetUserUpdateSettings(userID uint) (*UserUpdateSettings, error) {
|
||||
var settings UserUpdateSettings
|
||||
err := DB.Where("user_id = ?", userID).First(&settings).Error
|
||||
if err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
// Create default settings
|
||||
settings = UserUpdateSettings{
|
||||
UserID: userID,
|
||||
OAuthServiceURL: "https://oauth.trackeep.org",
|
||||
AutoUpdateCheck: false,
|
||||
UpdateCheckInterval: "24h",
|
||||
PrereleaseUpdates: false,
|
||||
}
|
||||
// Save defaults
|
||||
if err := DB.Create(&settings).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &settings, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &settings, nil
|
||||
}
|
||||
|
||||
// SaveUserUpdateSettings saves update settings for a user
|
||||
func SaveUserUpdateSettings(userID uint, settings *UserUpdateSettings) error {
|
||||
settings.UserID = userID
|
||||
return DB.Where("user_id = ?", userID).Assign(settings).FirstOrCreate(settings).Error
|
||||
}
|
||||
@@ -48,10 +48,14 @@ type User struct {
|
||||
LockedUntil *time.Time `json:"locked_until"`
|
||||
|
||||
// Privacy Settings
|
||||
ProfileVisibility string `json:"profile_visibility" gorm:"default:public"` // public, private, friends
|
||||
ShowEmail bool `json:"show_email" gorm:"default:false"`
|
||||
ShowActivity bool `json:"show_activity" gorm:"default:true"`
|
||||
AllowMessages bool `json:"allow_messages" gorm:"default:true"`
|
||||
ProfileVisibility string `json:"profile_visibility" gorm:"default:private"` // public, private, friends
|
||||
EmailNotifications bool `json:"email_notifications" gorm:"default:true"`
|
||||
PushNotifications bool `json:"push_notifications" gorm:"default:true"`
|
||||
|
||||
// Social Features
|
||||
ShowEmail bool `json:"show_email" gorm:"default:false"`
|
||||
ShowActivity bool `json:"show_activity" gorm:"default:true"`
|
||||
AllowMessages bool `json:"allow_messages" gorm:"default:true"`
|
||||
|
||||
// Social Stats
|
||||
FollowersCount int `json:"followers_count" gorm:"default:0"`
|
||||
|
||||
Reference in New Issue
Block a user