Files
MindSift/internal/storage/voice_input.go
T
sandrodachandClaude Opus 5.5 a927a94a95
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m40s
feat(voice): per-account choice between Whisper and the browser; STT_ALLOW_BROWSER
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 15:19:20 +01:00

29 lines
983 B
Go

package storage
import "errors"
// Everyone picks how their voice input works: the server's Whisper ("", the default) or the browser's
// recognition ("browser"). The server only offers the choice when it has a Whisper server and the
// browser is allowed (STT_ALLOW_BROWSER); the app applies it (lib/voice.ts).
var ErrInvalidVoiceInput = errors.New("Ungültige Spracheingabe (erlaubt: Whisper-Server oder Browser)")
func (s *Store) migrateVoiceInput() error {
return s.addColumnIfMissing("users", "voice_input", "TEXT NOT NULL DEFAULT ''")
}
// VoiceInput returns the user's choice: "" or "browser".
func (s *Store) VoiceInput(userID string) string {
var v string
_ = s.db.QueryRow(`SELECT voice_input FROM users WHERE id = ?`, userID).Scan(&v)
return v
}
func (s *Store) SetVoiceInput(userID, v string) error {
if v != "" && v != "browser" {
return ErrInvalidVoiceInput
}
_, err := s.db.Exec(`UPDATE users SET voice_input = ? WHERE id = ?`, v, userID)
return err
}