fix(pairing): broadcast pairing events for SQLite stores, not just PG

SetOnRequest was only wired for PGPairingStore via concrete type assertion.
Use interface-based assertion so SQLitePairingStore also gets the callback.
This fixes desktop app not receiving real-time pairing request notifications.
This commit is contained in:
viettranx committed 2026-03-27 20:27:25 +07:00
1 parent 0a8ca13d08
commit 2ba883aff7
1 file changed
+5 -1
+5 -1
View File
@@ -511,7 +511,11 @@ func runGateway() {
// Wire pairing event broadcasts to all WS clients.
pairingMethods.SetBroadcaster(server.BroadcastEvent)
if ps, ok := pgStores.Pairing.(*pg.PGPairingStore); ok {
// Wire pairing request callback — works for both PG and SQLite stores.
type pairingRequestNotifier interface {
SetOnRequest(func(code, senderID, channel, chatID string))
}
if ps, ok := pgStores.Pairing.(pairingRequestNotifier); ok {
ps.SetOnRequest(func(code, senderID, channel, chatID string) {
server.BroadcastEvent(*protocol.NewEvent(protocol.EventDevicePairReq, map[string]any{
"code": code, "sender_id": senderID, "channel": channel, "chat_id": chatID,