This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/server/store/sqlite/notification_prefs.go
Jeffrey Smith f0dd43144e rebrand: Switchboard Core → Armature
- Rename Go module switchboard-core → armature (155+ files)
- Rename Docker image → gobha/armature
- Rename K8s resources, secrets, deployments
- Rename Prometheus metrics switchboard_* → armature_*
- Rename env vars SWITCHBOARD_ADMIN_* → ARMATURE_ADMIN_*
- Rename DB names switchboard_core* → armature*
- Update all frontend branding, notification templates, docs
- Update CI scripts, e2e tests, Keycloak realm, nginx conf
- Rename scripts/switchboard-ca.sh → scripts/armature-ca.sh
- Rename k8s/switchboard.yaml → k8s/armature.yaml
- Rename chart alerting/dashboard files
- Fix: DockerHub push uses env: binding for secret injection
- Helm chart updated (name, labels, template functions, dashboard, alerting)
- Replace favicon/icon assets with Armature brand

No functional changes. Pure mechanical rename + CI fix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 21:39:58 +00:00

71 lines
2.0 KiB
Go

package sqlite
import (
"context"
"database/sql"
"armature/models"
"armature/store"
)
type NotificationPreferenceStore struct{}
func NewNotificationPreferenceStore() *NotificationPreferenceStore {
return &NotificationPreferenceStore{}
}
func (s *NotificationPreferenceStore) Get(ctx context.Context, userID, notifType string) (*models.NotificationPreference, error) {
var p models.NotificationPreference
err := DB.QueryRowContext(ctx, `
SELECT id, user_id, type, in_app, email
FROM notification_preferences
WHERE user_id = ? AND type = ?`, userID, notifType).Scan(
&p.ID, &p.UserID, &p.Type, &p.InApp, &p.Email)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, err
}
return &p, nil
}
func (s *NotificationPreferenceStore) ListForUser(ctx context.Context, userID string) ([]models.NotificationPreference, error) {
rows, err := DB.QueryContext(ctx, `
SELECT id, user_id, type, in_app, email
FROM notification_preferences
WHERE user_id = ?
ORDER BY type`, userID)
if err != nil {
return nil, err
}
defer rows.Close()
var result []models.NotificationPreference
for rows.Next() {
var p models.NotificationPreference
if err := rows.Scan(&p.ID, &p.UserID, &p.Type, &p.InApp, &p.Email); err != nil {
return nil, err
}
result = append(result, p)
}
return result, rows.Err()
}
func (s *NotificationPreferenceStore) Upsert(ctx context.Context, pref *models.NotificationPreference) error {
_, err := DB.ExecContext(ctx, `
INSERT INTO notification_preferences (id, user_id, type, in_app, email)
VALUES (?, ?, ?, ?, ?)
ON CONFLICT (user_id, type) DO UPDATE SET
in_app = excluded.in_app, email = excluded.email`,
store.NewID(), pref.UserID, pref.Type, pref.InApp, pref.Email)
return err
}
func (s *NotificationPreferenceStore) Delete(ctx context.Context, userID, notifType string) error {
_, err := DB.ExecContext(ctx, `
DELETE FROM notification_preferences
WHERE user_id = ? AND type = ?`, userID, notifType)
return err
}