mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 20:47:49 +08:00
refresh webui forms and fix whatsapp bridge login state
This commit is contained in:
@@ -1156,7 +1156,7 @@ func buildHeartbeatService(cfg *config.Config, msgBus *bus.MessageBus) *heartbea
|
||||
}
|
||||
|
||||
func setupEmbeddedWhatsAppBridge(ctx context.Context, cfg *config.Config) (*channels.WhatsAppBridgeService, bool) {
|
||||
if cfg == nil || !cfg.Channels.WhatsApp.Enabled || !shouldEmbedWhatsAppBridge(cfg) {
|
||||
if !shouldStartEmbeddedWhatsAppBridge(cfg) {
|
||||
return nil, false
|
||||
}
|
||||
cfg.Channels.WhatsApp.BridgeURL = embeddedWhatsAppBridgeURL(cfg)
|
||||
@@ -1169,6 +1169,10 @@ func setupEmbeddedWhatsAppBridge(ctx context.Context, cfg *config.Config) (*chan
|
||||
return svc, true
|
||||
}
|
||||
|
||||
func shouldStartEmbeddedWhatsAppBridge(cfg *config.Config) bool {
|
||||
return cfg != nil && shouldEmbedWhatsAppBridge(cfg)
|
||||
}
|
||||
|
||||
func shouldEmbedWhatsAppBridge(cfg *config.Config) bool {
|
||||
raw := strings.TrimSpace(cfg.Channels.WhatsApp.BridgeURL)
|
||||
if raw == "" {
|
||||
|
||||
32
cmd/cmd_gateway_test.go
Normal file
32
cmd/cmd_gateway_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
)
|
||||
|
||||
func TestShouldStartEmbeddedWhatsAppBridge(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cfg := config.DefaultConfig()
|
||||
cfg.Channels.WhatsApp.Enabled = false
|
||||
cfg.Channels.WhatsApp.BridgeURL = ""
|
||||
if !shouldStartEmbeddedWhatsAppBridge(cfg) {
|
||||
t.Fatalf("expected embedded bridge to start when using default embedded url")
|
||||
}
|
||||
|
||||
cfg.Channels.WhatsApp.BridgeURL = "ws://127.0.0.1:3001"
|
||||
if !shouldStartEmbeddedWhatsAppBridge(cfg) {
|
||||
t.Fatalf("expected embedded bridge to start for legacy local bridge url")
|
||||
}
|
||||
|
||||
cfg.Channels.WhatsApp.BridgeURL = "ws://example.com:3001/ws"
|
||||
if shouldStartEmbeddedWhatsAppBridge(cfg) {
|
||||
t.Fatalf("expected external bridge url to disable embedded bridge")
|
||||
}
|
||||
|
||||
if shouldStartEmbeddedWhatsAppBridge(nil) {
|
||||
t.Fatalf("expected nil config to disable embedded bridge")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user