MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 2m40s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
983 B
Go
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
|
|
}
|