package service import ( "vidarchive/internal/models" "vidarchive/internal/repository" ) type SettingsService struct { repo *repository.SettingsRepository } func NewSettingsService(repo *repository.SettingsRepository) *SettingsService { return &SettingsService{repo: repo} } func (s *SettingsService) GetAll() (*models.Settings, error) { return s.repo.GetAll() } func (s *SettingsService) SetRefreshInterval(interval string) error { return s.repo.Set("refresh_interval", interval) } func (s *SettingsService) SetAutoRefreshLibrary(enabled bool) error { val := "0" if enabled { val = "1" } return s.repo.Set("auto_refresh_library", val) } func (s *SettingsService) SetAutoRefreshDownloads(enabled bool) error { val := "0" if enabled { val = "1" } return s.repo.Set("auto_refresh_downloads", val) } func (s *SettingsService) SetCookies(cookies string) error { return s.repo.Set("cookies", cookies) } func (s *SettingsService) GetCookies() (string, error) { return s.repo.Get("cookies") } // GetSessionSecret returns the secret that signs login cookies, or "" when none // has been generated yet. It lives in the database so sessions survive a // restart, and is rotated on sign-out so cookies issued earlier stop verifying. func (s *SettingsService) GetSessionSecret() (string, error) { return s.repo.Get("session_secret") } func (s *SettingsService) SetSessionSecret(secret string) error { return s.repo.Set("session_secret", secret) }