chore(webui): rewrite all the web session code
All checks were successful
main / main (push) Successful in 3m13s
main / deploy (push) Has been skipped
main / publish (push) Has been skipped

#60
This commit is contained in:
Julien Dessaux 2025-04-29 01:25:11 +02:00
parent 929657fd34
commit 3bb5e735c6
Signed by: adyxax
GPG key ID: F92E51B86E07177E
19 changed files with 173 additions and 123 deletions

View file

@ -151,9 +151,12 @@ func (db *DB) LoadAccountUsernames() (map[string]string, error) {
return accounts, nil
}
func (db *DB) LoadAccountById(id uuid.UUID) (*model.Account, error) {
func (db *DB) LoadAccountById(id *uuid.UUID) (*model.Account, error) {
if id == nil {
return nil, nil
}
account := model.Account{
Id: id,
Id: *id,
}
var (
created int64
@ -239,11 +242,15 @@ func (db *DB) SaveAccount(account *model.Account) error {
func (db *DB) SaveAccountSettings(account *model.Account, settings *model.Settings) error {
data, err := json.Marshal(settings)
if err != nil {
return fmt.Errorf("failed to marshal settings for user %s: %w", account.Username, err)
return fmt.Errorf("failed to marshal settings for user account %s: %w", account.Username, err)
}
_, err = db.Exec(`UPDATE accounts SET settings = ? WHERE id = ?`, data, account.Id)
if err != nil {
return fmt.Errorf("failed to update settings for user %s: %w", account.Username, err)
return fmt.Errorf("failed to update account settings for user account %s: %w", account.Username, err)
}
_, err = db.Exec(`UPDATE sessions SET settings = ? WHERE account_id = ?`, data, account.Id)
if err != nil {
return fmt.Errorf("failed to update account settings for user account %s: %w", account.Username, err)
}
return nil
}