Refactor webpush store to eliminate code duplication

Consolidate SQLite and Postgres store implementations into a single
commonStore with database-specific SQL queries passed via configuration.
This eliminates ~100 lines of duplicate code while maintaining full
functionality for both backends.

Key changes:
- Move all store methods to commonStore in store.go
- Remove sqliteStore and postgresStore wrapper structs
- Refactor SQLite to use QueryRow() pattern like Postgres
- Pass database-specific queries via storeQueries struct
- Make store types unexported, only expose Store interface

All tests pass for both SQLite and PostgreSQL backends.
This commit is contained in:
binwiederhier
2026-02-16 19:53:34 -05:00
parent 869b972a50
commit 4e5f95ba0c
6 changed files with 173 additions and 272 deletions

View File

@@ -12,7 +12,7 @@ import (
"heckel.io/ntfy/v2/webpush"
)
func newTestPostgresStore(t *testing.T) *webpush.PostgresStore {
func newTestPostgresStore(t *testing.T) webpush.Store {
dsn := os.Getenv("NTFY_TEST_DATABASE_URL")
if dsn == "" {
t.Skip("NTFY_TEST_DATABASE_URL not set, skipping PostgreSQL tests")