GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
fix(chatwoot): preserve query params in per-device webhook URL (#801)
Aldino Kemalf82898846723
diff --git a/src/ui/rest/chatwoot_config.go b/src/ui/rest/chatwoot_config.goindex 0abd52d5..76fb24a6 100644--- a/src/ui/rest/chatwoot_config.go+++ b/src/ui/rest/chatwoot_config.go@@ -2,6 +2,7 @@ package restimport ("fmt"+ "net/url""strings""github.com/aldinokemal/go-whatsapp-web-multidevice/config"@@ -40,8 +41,11 @@ func maskAPIToken(token string) string {// Chatwoot inbox so agent replies route back to this device. Derived from the// configured public webhook base, or a relative path when none is set.func perDeviceWebhookURL(deviceID string) string {- if base := strings.TrimRight(strings.TrimSpace(config.ChatwootWebhookURL), "/"); base != "" {- return base + "/" + deviceID+ if base := strings.TrimSpace(config.ChatwootWebhookURL); base != "" {+ if webhookURL, err := url.JoinPath(base, deviceID); err == nil {+ return webhookURL+ }+ return strings.TrimRight(base, "/") + "/" + deviceID}return strings.TrimRight(config.AppBasePath, "/") + "/chatwoot/webhook/" + deviceID}diff --git a/src/ui/rest/chatwoot_config_url_test.go b/src/ui/rest/chatwoot_config_url_test.gonew file mode 100644index 00000000..48c9e1c6--- /dev/null+++ b/src/ui/rest/chatwoot_config_url_test.go@@ -0,0 +1,24 @@+package rest++import (+ "testing"++ "github.com/aldinokemal/go-whatsapp-web-multidevice/config"+)++func TestPerDeviceWebhookURLPreservesQuery(t *testing.T) {+ originalWebhookURL := config.ChatwootWebhookURL+ originalBasePath := config.AppBasePath+ defer func() {+ config.ChatwootWebhookURL = originalWebhookURL+ config.AppBasePath = originalBasePath+ }()++ config.ChatwootWebhookURL = "https://gowa.testdomain.com/chatwoot/webhook?secret=the-web-secret"+ config.AppBasePath = ""++ const want = "https://gowa.testdomain.com/chatwoot/webhook/the-device-id?secret=the-web-secret"+ if got := perDeviceWebhookURL("the-device-id"); got != want {+ t.Fatalf("perDeviceWebhookURL() = %q, want %q", got, want)+ }+}