feat: Added chat when MySQL is in use

This commit is contained in:
2026-06-21 02:30:01 +02:00
parent a9f2e515e1
commit 0e2ef317c3
10 changed files with 120 additions and 19 deletions
+9
View File
@@ -1,6 +1,7 @@
package main
import (
"database/sql"
"fmt"
"strings"
"time"
@@ -157,6 +158,7 @@ func (a *App) GetOnlineOperators() ([]ChatPresence, error) {
func (a *App) chatLoop() {
defer func() { _ = recover() }()
var lastID int64 = -1 // -1 = not yet baselined
var lastDB *sql.DB // logbook the baseline belongs to
lastPresence := time.Time{}
lastPurge := time.Time{}
t := time.NewTicker(chatPollInterval)
@@ -164,8 +166,15 @@ func (a *App) chatLoop() {
for range t.C {
if !a.chatActive() {
lastID = -1 // re-baseline if the backend changes
lastDB = nil
continue
}
// Profile switch swaps the logbook under us: re-baseline against the new
// DB so we don't query it with the previous log's id cursor.
if a.logDb != lastDB {
lastID = -1
lastDB = a.logDb
}
if err := a.ensureChatTables(); err != nil {
continue
}