Fix deployment issues and add threads, numbered watchlist, search URL encoding

- Fix SQLite connection string (drop query param, use explicit PRAGMA)
- Register sqlite3-fk-wal driver for mautrix cryptohelper (pure Go, no CGO)
- Fetch DeviceID via /whoami when using bare access token
- Log cross-signing results at Warn/Info instead of Debug
- Post deals into Matrix threads: Game Deals, DLC Deals, Epic Free Games
- Add numbered watchlist; !extend and !unwatch accept list numbers
- URL-encode search queries for multi-word !search commands
- Add GetConfig/SetConfig helpers for persistent thread event IDs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
prosolis
2026-03-17 20:54:15 -07:00
parent d6c8d4f599
commit e452e36a63
7 changed files with 539 additions and 28 deletions

View File

@@ -12,13 +12,16 @@ type DB struct {
}
func Open(path string) (*DB, error) {
db, err := sqlx.Open("sqlite", path+"?_pragma=journal_mode(WAL)")
db, err := sqlx.Open("sqlite", path)
if err != nil {
return nil, err
}
if err := db.Ping(); err != nil {
return nil, err
}
if _, err := db.Exec("PRAGMA journal_mode=WAL"); err != nil {
return nil, err
}
d := &DB{db: db}
if err := d.migrate(); err != nil {
return nil, err
@@ -97,6 +100,22 @@ func (d *DB) SetFirstRunDone() error {
return err
}
// GetConfig retrieves a value from the config table.
func (d *DB) GetConfig(key string) (string, error) {
var val string
err := d.db.Get(&val, "SELECT value FROM config WHERE key = ?", key)
return val, err
}
// SetConfig sets a value in the config table.
func (d *DB) SetConfig(key, value string) error {
_, err := d.db.Exec(
"INSERT OR REPLACE INTO config (key, value) VALUES (?, ?)",
key, value,
)
return err
}
// PruneOldDeals removes deals older than the given number of days.
func (d *DB) PruneOldDeals(days int) error {
cutoff := time.Now().AddDate(0, 0, -days).UTC().Format(time.RFC3339)