Phase 2 scaffold: mitra online status & pairing logic

Add mitra online/offline status with heartbeat-based auto-offline,
customer-mitra pairing via Valkey pub/sub blast, session management,
and control center dashboard with real-time stats.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 23:17:49 +08:00
parent a7a2a32d27
commit d668112edd
44 changed files with 2800 additions and 80 deletions

View File

@@ -15,3 +15,17 @@ export const setAnonymityConfig = async (enabled) => {
`
return { anonymity_enabled: enabled }
}
export const getMaxCustomersPerMitra = async () => {
const [row] = await sql`SELECT value FROM app_config WHERE key = 'max_customers_per_mitra'`
return { max_customers_per_mitra: row?.value?.value ?? 3 }
}
export const setMaxCustomersPerMitra = async (value) => {
await sql`
INSERT INTO app_config (key, value, updated_at)
VALUES ('max_customers_per_mitra', ${sql.json({ value })}, NOW())
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW()
`
return { max_customers_per_mitra: value }
}