refactor: migrate .webui_settings.json to database + fix NEW_CONTACT edge case

All settings (protected_contacts, cleanup_settings, retention_settings,
manual_add_contacts) moved from .webui_settings.json file to SQLite database.
Startup migration auto-imports existing file and renames it to .json.bak.

Added safeguard in _on_new_contact: if firmware fires NEW_CONTACT for a
contact already on the device, skip pending and log a warning. Also added
diagnostic logging showing previous DB state (source, protected) when
contacts reappear as pending.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-20 20:14:15 +01:00
parent e106b5493b
commit 4f25d244b1
7 changed files with 319 additions and 228 deletions
+7
View File
@@ -155,6 +155,13 @@ CREATE TABLE IF NOT EXISTS blocked_names (
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
-- Application settings (key-value store, replaces .webui_settings.json)
CREATE TABLE IF NOT EXISTS app_settings (
key TEXT PRIMARY KEY,
value TEXT NOT NULL DEFAULT '', -- JSON-encoded value
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
);
-- ============================================================
-- Indexes
-- ============================================================