This commit is contained in:
Ian Gulliver
2026-10-20 21:46:13 -07:00
parent 4680d7d2da
commit 4fdcc91061
4 changed files with 27 additions and 15 deletions
+3 -7
View File
@@ -3,18 +3,14 @@ package store
import (
"context"
"database/sql"
"encoding/json"
"g.fc.run/ai/byre/internal/api"
)
func (s *Store) UpdateNotificationPrefs(ctx context.Context, login string, prefs api.NotificationPrefs) (api.User, error) {
b, err := json.Marshal(prefs)
if err != nil {
return api.User{}, err
}
err = s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
_, err := tx.ExecContext(ctx, `UPDATE users SET notification_prefs = ? WHERE login = ?`, string(b), login)
err := s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
_, err := tx.ExecContext(ctx, `UPDATE users SET notify_questions = ?, notify_reports = ?, notify_errors = ?, notify_rate_limits = ?, notify_ready = ?, notify_discard = ?, notify_merge_problems = ?, notify_workflows = ? WHERE login = ?`,
prefs.Questions, prefs.Reports, prefs.Errors, prefs.RateLimits, prefs.Ready, prefs.Discard, prefs.MergeProblems, prefs.Workflows, login)
if err != nil {
return err
}