Firebase Cloud Messaging 1. Versuch

This commit is contained in:
concierge committed 2026-11-08 12:25:35 +01:00
1 parent f1fb926c2f
commit 4c8b11c4d5
25 files changed
+2111 -31

No files matched your search

+32
View File
@@ -148,12 +148,19 @@ CREATE TABLE IF NOT EXISTS ws_clients (
tenant_id INTEGER NOT NULL,
client_id TEXT NOT NULL,
account_id INTEGER NOT NULL,
-- Vom Client gemeldeter Typ. Nur 'group_view' und 'dispatcher_mobile'
-- sind für FCM-Aufwachsignale zugelassen.
client_type TEXT,
last_seq INTEGER NOT NULL DEFAULT 0,
worker_id TEXT,
authenticated INTEGER NOT NULL DEFAULT 0,
connected_at REAL,
disconnected_at REAL,
queue_started_at REAL,
-- Zeitpunkt und Grund des letzten FCM-Aufwachsignals. Verhindert, dass
-- mehrere Worker denselben Client im Sekundentakt wecken.
last_wake_at REAL,
last_wake_reason TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, client_id),
@@ -161,6 +168,25 @@ CREATE TABLE IF NOT EXISTS ws_clients (
FOREIGN KEY (account_id) REFERENCES accounts(id)
);
-- FCM-Registrierung pro Browserinstallation. Das Token ist projektweit
-- eindeutig; ein Browser kann deshalb nur einem Mandanten gleichzeitig
-- zugeordnet sein. Der eigentliche Inhalt bleibt in der WebSocket-Queue.
CREATE TABLE IF NOT EXISTS ws_push_tokens (
id INTEGER PRIMARY KEY AUTOINCREMENT,
tenant_id INTEGER NOT NULL,
client_id TEXT NOT NULL,
account_id INTEGER NOT NULL,
token TEXT UNIQUE NOT NULL,
client_type TEXT NOT NULL,
platform TEXT,
auto_position INTEGER NOT NULL DEFAULT 0,
invalid INTEGER NOT NULL DEFAULT 0,
created_at REAL NOT NULL,
updated_at REAL NOT NULL,
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
FOREIGN KEY (account_id) REFERENCES accounts(id)
);
-- Persistente Zustellaufträge pro Client. Jeder Worker liefert nur die
-- Aufträge seiner eigenen, lokal verbundenen Clients aus.
CREATE TABLE IF NOT EXISTS ws_client_queue (
@@ -238,6 +264,12 @@ CREATE INDEX IF NOT EXISTS idx_api_tokens_tenant
CREATE INDEX IF NOT EXISTS idx_ws_messages_ts ON ws_messages_store(ts);
CREATE INDEX IF NOT EXISTS idx_ws_clients_account
ON ws_clients(tenant_id, account_id);
CREATE INDEX IF NOT EXISTS idx_ws_clients_type
ON ws_clients(tenant_id, client_type, disconnected_at);
CREATE INDEX IF NOT EXISTS idx_ws_push_tokens_client
ON ws_push_tokens(tenant_id, client_id);
CREATE INDEX IF NOT EXISTS idx_ws_push_tokens_offline
ON ws_push_tokens(tenant_id, invalid, client_id);
CREATE INDEX IF NOT EXISTS idx_ws_client_queue_client
ON ws_client_queue(tenant_id, client_id, id);
CREATE INDEX IF NOT EXISTS idx_ws_client_queue_expires